Merge tip from an unrelated repository with Mercurial

前提是你 提交于 2019-12-10 16:46:26

问题


I have two unrelated repositories 'public' and 'develop':

prj/
  public/
  develop/

'develop' has lots of commits, 'cause here is where I work. Maybe even multiple heads From time to time I want publish a snapshot of the development repository.

From the public folder I could do this:

>hg pull -f ../develop
>hg merge
>hg commit -m "alpha2"

But this will also pull the complete changeset history from 'develop' to 'public' (which is not what I want).

I could also delete all files from 'public', except for the '.hg' subfolder. Then manually copy all files from the 'develop' directory and do a

>hg commit -m "alpha2"

But then I have to 'add' new files, 'remove' obsolete files and 'rename' moved files again.

Using the -A option with commit would blindly add/remove all files, even if they were uncontrolled in the 'development' repository.

There must be a more efficient way to do this ;-)


回答1:


I'd suggest you just move over the full history, but if you can't stomach that for some reason then you could do any of these things:

  1. use ConcatenatingChangesets to join all the changesets from develop into a single resulting changeset in public -or-
  2. delete all files in public, make a 'hg archive' in develop, and expand it in public -- that will get you controlled files only -or
  3. use 'hg manifest' in develop to power xargs to move over only files you want -or-
  4. do a 'hg diff -r last-changeset-in-public -r tip' in develop, and then apply that resulting diff using 'hg import' in public and you'll have the full changes as a single changeset in public

Any of those should do the same thing, but all of them are a little ugly because, in general, throwing away history is hard to do.



来源:https://stackoverflow.com/questions/1368080/merge-tip-from-an-unrelated-repository-with-mercurial

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!