代码之家  ›  专栏  ›  技术社区  ›  vaughan

保持一个风投持有开源项目mod最新,同时使用DVCS管理我的mod的变化

  •  1
  • vaughan  · 技术社区  · 14 年前

    我想用Mercurial来控制我的mod版本。(使用Mercurial的原因是我想跟踪变更集,这样我就可以将mod分解为组件—这对于使用OpenCart项目是必要的,例如,它不支持很好的扩展)。

    当开源项目更新时,我想把修改和我的mod合并起来。

    这将是理想的,如果原来的项目是在DVCS举行,因为我可以叉的项目和工作从那里,但唉,SVN的熟悉是保持其使用强大,这是固定的。

    所以我的问题是,对于这个场景,什么是理想的工作流,我如何实现它?

    3 回复  |  直到 14 年前
        1
  •  0
  •   Community CDub    8 年前

    补丁

    这在Mercurial页面中有部分说明。” Working with Subversion Repositories ".

    当您要为维护人员生成修补程序时,很简单:

     $ hg di -b -r last_svn_revision:your_tip > mybugfix.patch
    
        2
  •  1
  •   Ry4an Brase    14 年前

    Mercurial Queues quilt .

    使用mercurial和hg subversion,您可以将svn repo克隆为mercurial repo,然后对其使用MQ(或只是分支)来存储更改。当上游svn回购更新时,您将 pull 在未修改的hg subversion中创建克隆,然后合并到修改后的克隆中。

        3
  •  1
  •   Giorgos Keramidas    14 年前

    Mercurial Queues , Rebase Convert 用于跟踪堆积在上游源顶部的本地修改的扩展。

    转换 扩展以生成具有特定分支历史记录的本地Mercurial克隆,例如:

     ________
    (________)
    |        |  Subversion repository
    (________)
    
        |
        |    hg convert svn+ssh://host/repo/branch svn-branch
        |
        v
    .------------------.
    |                  |
    |  svn-branch/.hg  |
    |                  |
    `------------------'
    

    转换

    然后可以从中创建任意数量的本地克隆 svn-branch ,例如:

     ________
    (________)
    |        |  Subversion repository
    (________)
    
        |
        |    hg convert svn+ssh://host/repo/branch svn-branch
        |
        |
        |                                     .-------------.
        |                            .----->  |  feature-1  |
        v                            |        `-------------'
    .------------------.             |
    |                  |     clone   |        .-------------.
    |  svn-branch/.hg  |  -----------+----->  |  feature-2  |
    |                  |             |        `-------------'
    `------------------'             |
                                     |        .-------------.
                                     +----->  |  bugfix-1   |
                                              `-------------'
    

    设置本地克隆后,您可以为自己的修补程序提供两个选项:

    • 特征-1 特征-2 并继续与svn分支上游克隆“合并”
    • 保留您自己的更改 svn分公司 镜子。

    具有“正常”变更集的本地变更

    hg pull hg merge 跑步很理想。重复合并将很容易。冲突将是最小的。你可以记录什么时候,谁,什么合并了,为什么合并。更重要的是:你可以方便地 分享 出版 您的本地修改克隆与其他克隆。等等。

    和一个当地的 svn-branch/.hg 如果存储库的子版本历史大多是线性的,则重复的合并将如下所示(括号中的变更集是“仅本地”提交):

    [0] --- [1] --- [2] --- [4] --- [5] --- [7] --- [8] --- [9] --- [10]
                     \                \                               \
                      `-- (3) ------- (6) -------------------------- (11)
    

    变更集(3)中的本地更改对于上游Subversion人员是不可见的,但是您可以在本地历史中看到它们被合并了 两次

    hg diff -r 5:6
    hg diff -r 10:11
    

    您甚至可以在 命名 分支,例如通过提交(3)的更改:

    hg branch feature-1
    hg commit -m "Message"
    

    hg diff -r default:feature-1
    

    使用Mercurial队列的本地更改

    Mercurial队列 结合 重新基准 扩展使您可以轻松地将修补程序保持在本地svn镜像的“顶部”。重新调整本地修补程序的整个过程通常与以下步骤一样简单:

    # Incrementally pull changesets from the upstream Subversion
    # repository into a local hg clone:
    
      cd ~/work/svn-branch
      hg convert svn+ssh://host/repo/branch .
    
    # Rebase the local patches of 'feature-1' on top of the
    # latest subversion commits:
    
      cd ~/work/feature-1
      hg qpush -a && hg pull --rebase
    

    第一步是在svn分支镜像的一个克隆中创建本地“修补程序队列”:

    cd ~/work/feature-1
    hg qinit -c
    

    emacs src/foo.c
    hg qnew --git --force --edit
    

    您可以在原始svn分支提交的基础上创建任意数量的本地修补程序。例如,我的本地FreeBSD“head”镜像现在包括以下修补程序:

    keramida@kobe:/hg/bsd/src$ hg qseries -s
    newvers-hg-support: Include the hg changeset number to uname output too.
    kernconf-kobe: Add a kernel config file for my laptop, based on GENERIC
    truss-style: Style nits for lines that are too long after recent truss changes.
    yacc-core-dump: Fix a yacc(1) core dump reported by darrenr; patch by ru
    loader-prompt: Lowercase the "OK" prompt of the boot-loader
    top-rawcpu: Make top(1) use raw (non-weighted) cpu mode by default, like ps(1)
    nogames-mtree: Fix `make installworld' when WITHOUT_GAMES=yes.
    typo-fixes: Fix misc typos in source code comments & docs
    mg-00-import: Import a snapshot of the mg(1) editor from OpenBSD
    mg-01-freebsd-changes: Adapt the OpenBSD code of mg(1) to FreeBSD's environment
    mg-02-build: Attach the mg(1) editor to the FreeBSD build process
    regression-chmod: Add a few regression tests for chmod(1)
    regression-stdtime: Add a regression suite for libc/stdtime functions
    keramida@kobe:/hg/bsd/src$
    

    当然有可能保存一个包含数百个更改的本地堆栈。MQ对于本地开发补丁、微调补丁、拆分补丁或将它们加入到更大的补丁集中,以及与 重新基准 扩展它是一个强大的方法,让您的本地补丁集'移动'沿上游的历史。

    上一个示例中变更集(3)补丁的等效历史变更如下所示:

    # History snapshot #1 - the local changes in (3) as an
    # MQ patch P1 on top of changeset [2] from svn-branch:
    
    [0] --- [1] --- [2] --- (P1)
    

    svn分公司 克隆时,可以在最新的svn代码上重新设置本地P1修补程序的基础:

    # History snapshot #2 - patch P1 rebased from [2] to the
    # latest svn-base commit:
    
    [0] --- [1] --- [2] --- [3] --- [4] --- (P1')
                      .
                       . (P1) . . hg rebase . ^
    

    再过几天,您将更多的更改从subversion转换为 svn分公司 你又重新调整了基准:

    # History snapshot #3 - patch P1' rebased from [4] to the
    # latest svn-base commit, as a possibly very modified
    # version, shown as patch P1'':
    
    [0] --- [1] --- [2] --- [3] --- [4] --- [5] --- [6] --- [7] --- [8] ---  (P1'')
                                     .
                                       . (P1) . . . . hg rebase. . . . . . . . ^
    

    你可以尽可能多次地重新调整你的本地补丁。您甚至可以在每次迭代中重新设置多个修补程序的基础。您可以在多修补程序队列的“中间”插入修补程序。你可以删除补丁。您可以加入diff,将它们拆分为更多的面片,重新排列面片的堆叠顺序。通常,您可以根据需要多次、频繁地重写和微调修补程序队列。