12

这可能看起来很矛盾,我知道秘密变更集是私有的,但是如果我想备份这些秘密变更集怎么办?

我与一些分支并行工作,有时我想推动一个,而不是其他的。为了实现这一点,我在不同的克隆中工作,但我讨厌这样。

所以现在 mercurial 有了阶段,我可以创建秘密分支并将所有内容都放在同一个存储库中。问题是在秘密分支的开始和它的发布之间,我想备份那些秘密变更集(我在另一台机器上有一个克隆只是为了保存我的备份,以防我的本地仓库或我的机器发生问题)。

有没有办法做到这一点,或者我的工作流程完全错误?

4

6 回答 6

5

无需标记任何秘密。如果您只想推送一个分支,请使用:

hg push -r REV

这只会推动 REV 及其祖先。

Secret 对 Mercurial 补丁队列修订很有用,因为它们无论如何都不能被推送,并且它可以防止本地克隆复制它们。

Draft 非常适合跟踪未推送的更改。如果您仍想备份它们,推送它们会将它们翻转为公开,但您可以将它们重置为草稿(与另一个存储库相比):

hg phase -fd 'outgoing(URL)'

(默认推送存储库的 URL 可以为空)。

于 2012-04-06T05:31:46.253 回答
3

似乎阶段仍然相对较新,并且一些工作流程,例如这个,似乎还没有被包括在内。截至 2013 年 3 月 19 日,我相信您可以做到这一点的唯一方法是手动将阶段从秘密更改为公开。

您可以从命令行使用这些命令:

for /f "delims=" %a in ('hg log --template "{rev} " -r "secret()"') do @set secret=%a
hg phase -d %secret%
hg push -f
hg phase -sf %secret%

这不会更改您要推送到的存储库上对秘密的提交,我尝试更改推送以执行此操作(但不成功):

hg push -f --remotecmd hg phase -sf %secret%

提交必须完全匹配remote hg command才能工作,但无论如何我无法让它在远程存储库上进行更改。

==================================================== ==========

如果您想使用像 TortoiseHG Workbench 这样的 GUI,您现在必须手动完成所有操作(在您想要的任何存储库上更改 GUI 中的阶段)。抱歉,希望我们能尽快找到更好的解决方案!

于 2013-03-19T20:38:16.187 回答
2

The best approach is a combination of @mischab1's answer, @mark-tolonen's answer and aliases.

By following mischab1's answer, you make sure that pushing to your backup location will not change the phase to "public".

Second step would be to add the backup location to your repository's hgrc/paths:

[paths]
default = ...
backup = backup_location

The next step is to define a backup command via alias in the global hgrc, e.g. "bubr" (for backup current branch) or "burev" (backup current rev).

[alias]
bubr = push -b . backup
burev = push -r . backup

hg bubr or hg burev will then push the current branch/revision to the location defined as "backup" path.

Edit This still has the drawback that you could accidentally push all changes with "hg push" so defining also an hg pubr command to push the current branch and not using "hg push" per default might be helpful.

于 2013-06-11T14:44:28.887 回答
0
@echo off
rem hgfullpull_naive.cmd
setlocal
set SRC_REPO=%~f1
set DST_REPO=%~f2
set TMP_DIR=%TEMP%\%~n0.tmp
set NODES_LIST=%TMP_DIR%\%~n0.%RANDOM%.tmp

if "%SRC_REPO%"=="" exit /b 1
if "%DST_REPO%"=="" exit /b 1
if "%SRC_REPO%"=="%DST_REPO%" exit /b 1

call :ALL
del /Q "%NODES_LIST%"
endlocal
goto :eof

:ALL
    md "%TMP_DIR%"
    hg log --rev "secret()" --template "{node}\n" --repository "%SRC_REPO%" >"%NODES_LIST%" || exit /b 1
    call :CHANGE_PHASE "%SRC_REPO%" --draft
    hg pull --repository "%DST_REPO%" "%SRC_REPO%"
    call :CHANGE_PHASE "%SRC_REPO%" --secret
    call :CHANGE_PHASE "%DST_REPO%" --secret
    goto :eof

:CHANGE_PHASE 
    setlocal
    set REPO=%~1
    set PHASE=%~2
    for /F "eol=; delims= usebackq" %%i IN ("%NODES_LIST%") DO (hg phase %PHASE% --force --rev %%i --repository "%REPO%")
    endlocal
    goto :eof
于 2017-12-27T18:07:24.087 回答
0

这是迄今为止我想出的最好的。我认为它基本上等同于您希望推/拉能够做的事情。

  1. 将您要传输的所有秘密变更集标记为草稿
  2. 在源代码库中运行hg bundle -r last_draft_rev bundlefile.hg path\to\backup\repo
  3. 在目标仓库中运行hg unbundle bundlefile.hg
  4. 变更集将作为草稿进入备份
  5. 将第一个草稿变更集标记为秘密,它的所有后代都将被标记为秘密

如果变更集仍被标记为机密,我无法让#2 工作。

于 2017-11-17T19:33:37.900 回答
-1

现在最简单的事情是通过将以下内容添加到其 hgrc 配置文件中来将备份存储库标记为非发布。

[phases]
publish = False

有关更多信息,请参阅Mercurial 的 Wiki

于 2013-03-23T00:54:45.617 回答