简体   繁体   English

如何拆分商品库?

[英]how can I split a mercurial repository?

The format of the hg mv command is hg rename [OPTION]... SOURCE... DEST . hg mv命令的格式为hg named hg rename [OPTION]... SOURCE... DEST Path names are relative to the current directory. 路径名是相对于当前目录的。 Thus, when you are at a command prompt at the root directory and specify hg mv -n -I * A\\BZ , mercurial will create the directory Z under the root directory, and move A\\B\\readme.txt to Z\\readme.txt. 因此,当您在根目录的命令提示符下并指定hg mv -n -I * A\\BZ ,mercurial将在根目录下创建目录Z,并将A \\ B \\ readme.txt移至Z \\ readme 。文本。

How can you specify, under Windows, that Z is the repository root directory? 在Windows下,如何指定Z是存储库的根目录? I tried using '.' 我尝试使用“。” as destination, ie hg mv -n -I * A\\B . 作为目的地,即hg mv -n -I * A\\B . but got a message that A\\B\\readme.txt will be copied to B\\readme.txt, not to readme.txt at the root. 但是收到一条消息,说A \\ B \\ readme.txt将被复制到B \\ readme.txt,而不是根目录下的readme.txt。 I tried using '~' as the destination, but hg mv -n -I * A\\B ~ got me a new directory named "~" below the root, obviously not what I wanted. 我尝试使用“〜”作为目的地,但是hg mv -n -I * A\\B ~在根目录下找到了一个名为“〜”的新目录,显然不是我想要的目录。

So my question is: How do I specify the repository root directory as the destination to the mercurial move command? 所以我的问题是: 如何将存储库根目录指定为Mercurial move命令的目标?


edit : I'll try to clarify the issue. 编辑 :我将尝试澄清问题。

I have an OldDev repository containing two products: Product-A and Product-B. 我有一个包含两个产品的OldDev存储库:产品A和产品B。 Using the '~' symbol to denote OldDev's root folder, OldDev contains two folders: ~/Product-A and ~/Product-B (in addition, of course, to ~/.hg where its metadata is stored). 使用“〜”符号表示OldDev的根文件夹,OldDev包含两个文件夹:〜/ Product-A和〜/ Product-B(当然,此外还有〜/ .hg存储元数据的位置)。

Each product is composed of a few projects, and each such project is assigned a folder under the product's folder. 每个产品由几个项目组成,并且每个此类项目都在产品的文件夹下分配了一个文件夹。 Thus Product-A has the Project-A, Project-B and Project-C, stored in ~/Product-A/Project-A, ~/Product-A/Project-B and ~/Product-A/Project-C, correspondingly. 因此,产品A具有项目A,项目B和项目C,分别存储在〜/ Product-A / Project-A,〜/ Product-A / Project-B和〜/ Product-A / Project-C中,相应地。 ~/Product-A/Project-A/xxx.cs is one of (Product-A's) Project-A's files. 〜/ Product-A / Project-A / xxx.cs是(Product-A的)Project-A的文件之一。

Now I want to extract Project-A to its own NewDev repository. 现在,我想将Project-A提取到其自己的NewDev存储库中。 As it's the single project in NewDev, it makes no sense to retain the product/project hierarchy, so I want it to be at the root of NewDev: it xxx.cs file, for example, will be @/xxx.cs, where @ is the root folder of NewDev (the one contianing NewDev's .hg directory where NewDev's metadata is stored). 由于它是NewDev中的单个项目,因此保留产品/项目层次结构没有任何意义,因此我希望它位于NewDev的根目录:例如,它的xxx.cs文件将是@ / xxx.cs,其中@是NewDev的根文件夹(该文件夹包含NewDev的元数据存储在NewDev的.hg目录中)。

To extract Project-A to NewDev I used the the convert extension, as documented in " split a repository in two ". 要将Project-A提取到NewDev,我使用了转换扩展名,如“ 将存储库分成两部分 ”中所述。 I used a mapfile containing the one mapping include Product-A/Project-A . 我使用了一个映射文件,其中包含一个映射include Product-A/Project-A

So far, NewDev is an exact subtree of OldDev. 到目前为止,NewDev是OldDev的确切子树。 It does not contain ~/Product-B, it does not contain ~/Product-A/Project-B nor ~/Product-A/Project-C. 它不包含〜/ Product-B,也不包含〜/ Product-A / Project-B或〜/ Product-A / Project-C。 It only contains ~/Product-A/Project-A. 它仅包含〜/ Product-A / Project-A。 The files that remained are located at exactly the same paths as before, but only those files that belong to Product-A's Project-A were retained. 剩余的文件位于与以前完全相同的路径中,但是仅保留了属于Product-A的Project-A的那些文件。

So, I've achieved half of my goals: I split OldDev, with its many products and projects, and created NewDev with only one project (Project-A). 因此,我已经实现了一半目标:我拆分了OldDev及其许多产品和项目,并仅使用一个项目(Project-A)创建了NewDev。 However, the files of Project-A are not at @ but at their old (OldDev) location @/Product-A/Project-A. 但是,Project-A的文件不是位于@,而是位于其旧(OldDev)位置@ / Product-A / Project-A。 I need to move them up two steps so xxx.cs, will be at @/xxx.cs and not at @/Product-A/Project-A/xxx.cs 我需要将它们向上移动两步,所以xxx.cs将位于@ / xxx.cs而不是@ / Product-A / Project-A / xxx.cs

To move the files I tried to use the hg mv command, but I can't figure how to specify the root (@) as the destination. 要移动文件,我尝试使用hg mv命令,但是我无法确定如何将根(@)指定为目标。

Solution : What worked for me, based on Marc Anton Dahmen's answer, is as follows: 解决方案 :根据马克·安东·达门的回答,对我有用的内容如下:

convert1.txt: hg convert -s hg -d hg --filemap mapfile1.txt olddev temprepo
mapfile1.txt: include Product-A/Project-A

convert2.txt: hg convert -s hg -d hg --filemap mapfile2.txt temprepo newrepo
mapfile2.txt: rename Product-A/Project-A .

Where the text of convrert1.txt and convert2.txt, of course, shell commands. 其中convrert1.txt和convert2.txt的文本,当然是shell命令。

您必须在文件映射中使用重命名指令,而不要像这样包含

rename Project-A .

Moving every file in a repository and the repository data is not an hg mv operation because that cannot change where the repository meta-data is stored. 移动存储库中的每个文件和存储库数据不是hg mv操作,因为它不能更改存储库元数据的存储位置。

The wording of your question is still really ambiguous, but I have a decent guess as to what you want to do. 您的问题的措词仍然很含糊,但我对您要做什么有一个不错的猜测。

Suppose you have a repo called /some/dir/avi-repo and you really want it to be in /avi-repo. 假设您有一个名为/ some / dir / avi-repo的存储库,并且您确实希望它位于/ avi-repo中。 Use clone: 使用克隆:

cd /
hg clone /some /avi-repo

Now you have two identical copies of the repo, one in /some/dir/avi-repo and one in /avi-repo . 现在,您有两个相同的repo副本,一个在/some/dir/avi-repo ,一个在/avi-repo You can delete all of /some/dir/avi-repo now. 您现在可以删除所有/some/dir/avi-repo

Your desire seems a little more complicated than that with a tree like: 您的愿望似乎比像这样的树更复杂:

/some
 ---- /.hg  # the repository meta-data
 ---- /dir  # no files in here just the sub-dir
 -------- /avi-repo
 ------------/file.c
 ------------/file.dat
 ------------/important-file.txt

And you want to move avi-repo to /some/avi-repo . 您想将avi-repo移至/some/avi-repo You should be able to do that with the right sequence of mercurial commands, but it is far easier to: 您应该能够按照正确的顺序执行该命令,但是要容易得多:

mkdir /temp
cd /temp
hg clone /some /temp/avi-clone
rm -r /some
mkdir /some
hg clone /temp/avi-clone /some

Or some variant of that. 或其他形式。 The point is that repatriating an entire repository is not a job for hg mv . 关键是,对于hg mv来说,遣返整个存储库不是一项工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM