Mercurial > hg
view tests/test-walkrepo.py @ 13033:026053f691a4
mq: add an '-e/--exact' option to qpush
This patch adds an '--exact/-e' option to qpush that will try to push the
patches in the correct location in the DAG. Specifying this option does the
following:
* If --move is specified, abort. It makes no sense to move a patch to the front
of the queue and try to apply it to its parent, because its parent is one of
the patches we just moved it in front of!
* If patches are already applied, abort. We don't want patch changesets
scattered throughout the DAG.
* If local changes are present, abort unless --force is used, as usual.
* Find the first patch we're going to push (if we're pushing multiple patches
with a target or --all).
* If that patch doesn't have a parent, abort, obviously.
* If the parent doesn't exist in the repo, abort. Something is wrong.
* Update to the parent, then continue pushing the patches as normal.
author | Steve Losh <steve@stevelosh.com> |
---|---|
date | Wed, 17 Nov 2010 21:18:44 -0500 |
parents | 284fda4cd093 |
children | 938fbeacac84 |
line wrap: on
line source
import os from mercurial import hg, ui from mercurial.util import walkrepos from os import mkdir, chdir from os.path import join as pjoin u = ui.ui() sym = hasattr(os, 'symlink') and hasattr(os.path, 'samestat') hg.repository(u, 'top1', create=1) mkdir('subdir') chdir('subdir') hg.repository(u, 'sub1', create=1) mkdir('subsubdir') chdir('subsubdir') hg.repository(u, 'subsub1', create=1) chdir(os.path.pardir) if sym: os.symlink(os.path.pardir, 'circle') os.symlink(pjoin('subsubdir', 'subsub1'), 'subsub1') def runtest(): reposet = frozenset(walkrepos('.', followsym=True)) if sym and (len(reposet) != 3): print "reposet = %r" % (reposet,) print "Found %d repositories when I should have found 3" % (len(reposet),) if (not sym) and (len(reposet) != 2): print "reposet = %r" % (reposet,) print "Found %d repositories when I should have found 2" % (len(reposet),) sub1set = frozenset((pjoin('.', 'sub1'), pjoin('.', 'circle', 'subdir', 'sub1'))) if len(sub1set & reposet) != 1: print "sub1set = %r" % (sub1set,) print "reposet = %r" % (reposet,) print "sub1set and reposet should have exactly one path in common." sub2set = frozenset((pjoin('.', 'subsub1'), pjoin('.', 'subsubdir', 'subsub1'))) if len(sub2set & reposet) != 1: print "sub2set = %r" % (sub2set,) print "reposet = %r" % (reposet,) print "sub1set and reposet should have exactly one path in common." sub3 = pjoin('.', 'circle', 'top1') if sym and not (sub3 in reposet): print "reposet = %r" % (reposet,) print "Symbolic links are supported and %s is not in reposet" % (sub3,) runtest() if sym: # Simulate not having symlinks. del os.path.samestat sym = False runtest()