Best way to push new subrepositories replacing a normal directory?
Benjamin Fritz
fritzophrenic at gmail.com
Thu Dec 4 18:17:16 UTC 2014
I decided to convert my Vim configuration in Mercurial to use
subrepositories for many of my plugins, rather than copying the files in
manually and tracking them as part of my "main" repository.
So, I cloned my current config to a temporary location. I did "hg remove"
to get rid of the existing sets of files for each plugin. Then I did "hg
clone" or "git clone" (depending on the plugin) to get new clones of each
of those repositories. Then I created a .hgsub file to set them all up as
subrepositories, following the recommended practice of using only "simple"
source paths, added it, and committed the whole lot:
bundle/AutoFenc = [git]bundle/AutoFenc
bundle/autohide = bundle/autohide
bundle/easy-align = [git]bundle/easy-align
bundle/gundo = bundle/gundo
bundle/mru = [git]bundle/mru
bundle/pathogen = [git]bundle/pathogen
bundle/repeat = [git]bundle/repeat
bundle/signify = [git]bundle/signify
bundle/surround = [git]bundle/surround
bundle/tagbar = [git]bundle/tagbar
bundle/unicode-complete = [git]bundle/unicode-complete
All this seemed to work beautifully, until I tried pushing the changes back
to my working config repository. The push failed, because the
subrepositories don't yet exist in the push destination.
(Note, at this point, I was fairly sure I could pull into my working
repository from my temp repository, but I decided to be stubborn and figure
out how to push)
I figured I'd be able to push if I set up absolute rather than simple
source paths for all my subrepositories, so I did so:
bundle/AutoFenc = [git]https://github.com/s3rvac/AutoFenc.git
bundle/autohide = https://code.google.com/p/vim-autohide-plugin/
bundle/easy-align = [git]https://github.com/junegunn/vim-easy-align.git
bundle/gundo = https://bitbucket.org/sjl/gundo.vim
bundle/mru = [git]https://github.com/yegappan/mru.git
bundle/pathogen = [git]https://github.com/tpope/vim-pathogen.git
bundle/repeat = [git]https://github.com/tpope/vim-repeat.git
bundle/signify = [git]https://github.com/mhinz/vim-signify.git
bundle/surround = [git]https://github.com/tpope/vim-surround.git
bundle/tagbar = [git]https://github.com/majutsushi/tagbar.git
bundle/unicode-complete = [git]https://github.com/chrisbra/unicode.vim.git
This allowed me to push without error. But my very next commit changes the
file back! That can't be the best way to do it.
The problems continued.
I went to my working repository to update it to get the new
subrepositories. I got an error from git saying that it could not clone
into a non-empty directory! Remember, I removed the old directory and added
the subrepository in the same commit. So I tried manually deleting the old
directories before the update, which obviously gives an error about the
working copy not being clean. I did eventually get where I wanted by doing
a clean update, then pushing the final changeset and updating to restore
the simple repository paths.
All this worked for me, but I worry in the future, that pushing to some
"central" repository like BitBucket will fail.
So...how SHOULD I have handled this, to get my desired result of replacing
"normal" directories containing copies of a 3rd-party project, with a
subrepository of the actual project?
--
Ben Fritz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial/attachments/20141204/4a7890da/attachment.html>
More information about the Mercurial
mailing list