Mercurial > hg-stable
changeset 16036:e6e12e60a45f stable
merge with i18n
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 30 Jan 2012 14:14:18 -0600 |
parents | 308406677e9d (diff) b2392a395fcf (current diff) |
children | 9232fa4fd1ba |
files | |
diffstat | 17 files changed, 169 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Mon Jan 30 16:28:27 2012 +0100 +++ b/hgext/mq.py Mon Jan 30 14:14:18 2012 -0600 @@ -826,9 +826,13 @@ return patches def finish(self, repo, revs): + # Manually trigger phase computation to ensure phasedefaults is + # executed before we remove the patches. + repo._phaserev patches = self._revpatches(repo, sorted(revs)) qfinished = self._cleanup(patches, len(patches)) - if qfinished: + if qfinished and repo.ui.configbool('mq', 'secret', False): + # only use this logic when the secret option is added oldqbase = repo[qfinished[0]] if oldqbase.p1().phase() < phases.secret: phases.advanceboundary(repo, phases.draft, qfinished) @@ -1511,6 +1515,8 @@ user = ph.user or changes[1] + oldphase = repo[top].phase() + # assumes strip can roll itself back if interrupted repo.dirstate.setparents(*cparents) self.applied.pop() @@ -1523,8 +1529,15 @@ try: # might be nice to attempt to roll back strip after this - n = secretcommit(repo, message, user, ph.date, match=match, - force=True) + backup = repo.ui.backupconfig('phases', 'new-commit') + try: + # Ensure we create a new changeset in the same phase than + # the old one. + repo.ui.setconfig('phases', 'new-commit', oldphase) + n = repo.commit(message, user, ph.date, match=match, + force=True) + finally: + repo.ui.restoreconfig(backup) # only write patch after a successful commit patchf.close() self.applied.append(statusentry(n, patchfn)) @@ -1823,6 +1836,9 @@ self.added.append(patchname) patchname = None + if rev and repo.ui.configbool('mq', 'secret', False): + # if we added anything with --rev, we must move the secret root + phases.retractboundary(repo, phases.secret, [n]) self.parseseries() self.applieddirty = True self.seriesdirty = True @@ -1997,16 +2013,21 @@ Returns 0 if import succeeded. """ - q = repo.mq + lock = repo.lock() # cause this may move phase try: - q.qimport(repo, filename, patchname=opts.get('name'), - existing=opts.get('existing'), force=opts.get('force'), - rev=opts.get('rev'), git=opts.get('git')) + q = repo.mq + try: + q.qimport(repo, filename, patchname=opts.get('name'), + existing=opts.get('existing'), force=opts.get('force'), + rev=opts.get('rev'), git=opts.get('git')) + finally: + q.savedirty() + + + if opts.get('push') and not opts.get('rev'): + return q.push(repo, None) finally: - q.savedirty() - - if opts.get('push') and not opts.get('rev'): - return q.push(repo, None) + lock.release() return 0 def qinit(ui, repo, create): @@ -3142,8 +3163,12 @@ def mqphasedefaults(repo, roots): """callback used to set mq changeset as secret when no phase data exists""" if repo.mq.applied: + if repo.ui.configbool('mq', 'secret', False): + mqphase = phases.secret + else: + mqphase = phases.draft qbase = repo[repo.mq.applied[0].node] - roots[phases.secret].add(qbase.node()) + roots[mqphase].add(qbase.node()) return roots def reposetup(ui, repo):
--- a/mercurial/commands.py Mon Jan 30 16:28:27 2012 +0100 +++ b/mercurial/commands.py Mon Jan 30 14:14:18 2012 -0600 @@ -4226,17 +4226,20 @@ if not revs: raise util.Abort(_('no revisions specified')) + revs = scmutil.revrange(repo, revs) + lock = None ret = 0 if targetphase is None: # display - for ctx in repo.set('%lr', revs): + for r in revs: + ctx = repo[r] ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr())) else: lock = repo.lock() try: # set phase - nodes = [ctx.node() for ctx in repo.set('%lr', revs)] + nodes = [ctx.node() for ctx in repo.set('%ld', revs)] if not nodes: raise util.Abort(_('empty revision set')) olddata = repo._phaserev[:] @@ -4260,11 +4263,16 @@ if modheads == 0: return if optupdate: + movemarkfrom = repo['.'].node() try: - return hg.update(repo, checkout) + ret = hg.update(repo, checkout) except util.Abort, inst: ui.warn(_("not updating: %s\n" % str(inst))) return 0 + if not ret and not checkout: + if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): + ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent) + return ret if modheads > 1: currentbranchheads = len(repo.branchheads()) if currentbranchheads == modheads: @@ -4414,14 +4422,14 @@ c = repo[''] subs = c.substate # only repos that are committed for s in sorted(subs): - if not c.sub(s).push(opts): + if c.sub(s).push(opts) == 0: return False finally: del repo._subtoppath result = repo.push(other, opts.get('force'), revs=revs, newbranch=opts.get('new_branch')) - result = (result == 0) + result = not result if opts.get('bookmark'): rb = other.listkeys('bookmarks') @@ -4443,6 +4451,7 @@ ui.warn(_('updating bookmark %s failed!\n') % b) if not result: result = 2 + result = 0 return result
--- a/mercurial/localrepo.py Mon Jan 30 16:28:27 2012 +0100 +++ b/mercurial/localrepo.py Mon Jan 30 14:14:18 2012 -0600 @@ -1268,8 +1268,7 @@ parent2=xp2, pending=p) self.changelog.finalize(trp) # set the new commit is proper phase - targetphase = self.ui.configint('phases', 'new-commit', - phases.draft) + targetphase = phases.newcommitphase(self.ui) if targetphase: # retract boundary do not alter parent changeset. # if a parent have higher the resulting phase will @@ -1592,7 +1591,8 @@ def push(self, remote, force=False, revs=None, newbranch=False): '''Push outgoing changesets (limited by revs) from the current repository to remote. Return an integer: - - 0 means HTTP error *or* nothing to push + - None means nothing to push + - 0 means HTTP error - 1 means we pushed and remote head count is unchanged *or* we have outgoing changesets but refused to push - other values as described by addchangegroup() @@ -1626,7 +1626,7 @@ if not outgoing.missing: # nothing to push scmutil.nochangesfound(self.ui, outgoing.excluded) - ret = 1 + ret = None else: # something to push if not force: @@ -1679,13 +1679,13 @@ # We can pick: # * missingheads part of comon (::commonheads) common = set(outgoing.common) - cheads = [n for node in revs if n in common] + cheads = [node for node in revs if node in common] # and # * commonheads parents on missing - rvset = repo.revset('%ln and parents(roots(%ln))', - outgoing.commonheads, - outgoing.missing) - cheads.extend(c.node() for c in rvset) + revset = self.set('%ln and parents(roots(%ln))', + outgoing.commonheads, + outgoing.missing) + cheads.extend(c.node() for c in revset) # even when we don't push, exchanging phase data is useful remotephases = remote.listkeys('phases') if not remotephases: # old server or public only repo
--- a/mercurial/phases.py Mon Jan 30 16:28:27 2012 +0100 +++ b/mercurial/phases.py Mon Jan 30 14:14:18 2012 -0600 @@ -122,6 +122,7 @@ raise for f in repo._phasedefaults: roots = f(repo, roots) + repo._dirtyphases = True return roots def writeroots(repo): @@ -297,3 +298,20 @@ heads, roots, roots, heads) return [c.node() for c in revset] + +def newcommitphase(ui): + """helper to get the target phase of new commit + + Handle all possible values for the phases.new-commit options. + + """ + v = ui.config('phases', 'new-commit', draft) + try: + return phasenames.index(v) + except ValueError: + try: + return int(v) + except ValueError: + msg = _("phases.new-commit: not a valid phase name ('%s')") + raise error.ConfigError(msg % v) +
--- a/mercurial/subrepo.py Mon Jan 30 16:28:27 2012 +0100 +++ b/mercurial/subrepo.py Mon Jan 30 14:14:18 2012 -0600 @@ -528,7 +528,7 @@ c = self._repo[''] subs = c.substate # only repos that are committed for s in sorted(subs): - if not c.sub(s).push(opts): + if c.sub(s).push(opts) == 0: return False dsturl = _abssource(self._repo, True)
--- a/tests/test-inherit-mode.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-inherit-mode.t Mon Jan 30 14:14:18 2012 -0600 @@ -121,6 +121,7 @@ 00660 ../push/.hg/store/data/dir/bar.i 00660 ../push/.hg/store/data/foo.i 00660 ../push/.hg/store/fncache + 00660 ../push/.hg/store/phaseroots 00660 ../push/.hg/store/undo 00660 ../push/.hg/store/undo.phaseroots 00660 ../push/.hg/undo.bookmarks
--- a/tests/test-mq-qimport.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-mq-qimport.t Mon Jan 30 14:14:18 2012 -0600 @@ -226,3 +226,19 @@ $ cd ../repo $ hg qimport http://localhost:$HGPORT/raw-rev/0/// adding 0 to series file + +check qimport phase: + + $ hg -q qpush + now at: 0 + $ hg phase qparent + 1: draft + $ hg qimport -r qparent + $ hg phase qbase + 1: draft + $ hg qfinish qbase + $ echo '[mq]' >> $HGRCPATH + $ echo 'secret=true' >> $HGRCPATH + $ hg qimport -r qparent + $ hg phase qbase + 1: secret
--- a/tests/test-mq-qrefresh.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-mq-qrefresh.t Mon Jan 30 14:14:18 2012 -0600 @@ -523,3 +523,23 @@ diff --git a/a b/a new file mode 100644 $ cd .. + +Refresh with phase data: + + + + $ cd repo + $ echo 'babar' >> a + $ hg qnew -m 'update a' p2.diff + $ hg phase p2.diff + 2: draft + $ echo 'beber' >> a + $ hg qref + $ hg phase p2.diff + 2: draft + $ hg phase --force --secret p2.diff + $ echo 'bibir' >> a + $ hg qref + $ hg phase p2.diff + 2: secret +
--- a/tests/test-mq-safety.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-mq-safety.t Mon Jan 30 14:14:18 2012 -0600 @@ -173,6 +173,7 @@ pushing to ../forcepush2 searching for changes no changes found (ignored 1 secret changesets) + [1] $ hg phase --draft 'mq()' $ hg push --force -r default ../forcepush2 pushing to ../forcepush2
--- a/tests/test-mq.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-mq.t Mon Jan 30 14:14:18 2012 -0600 @@ -1448,4 +1448,38 @@ applying modify-file now at: modify-file - $ cd .. +Proper phase default with mq: + +1. mq.secret=false + + $ rm .hg/store/phaseroots + $ hg phase 'qparent::' + 0: draft + 1: draft + 2: draft + $ echo '[mq]' >> $HGRCPATH + $ echo 'secret=true' >> $HGRCPATH + $ rm -f .hg/store/phaseroots + $ hg phase 'qparent::' + 0: secret + 1: secret + 2: secret + +Test that qfinish change phase when mq.secret=true + + $ hg qfinish qbase + patch add-file1 finalized without changeset message + $ hg phase 'all()' + 0: draft + 1: secret + 2: secret + +Test that qfinish preserve phase when mq.secret=false + + $ sed -i'' $HGRCPATH -e 's/secret=true/secret=false/' + $ hg qfinish qbase + patch add-file2 finalized without changeset message + $ hg phase 'all()' + 0: draft + 1: secret + 2: secret
--- a/tests/test-phases-exchange.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-phases-exchange.t Mon Jan 30 14:14:18 2012 -0600 @@ -98,6 +98,7 @@ pushing to ../beta searching for changes no changes found + [1] $ hgph @ 3 public a-D - b555f63b6063 | @@ -372,6 +373,7 @@ pushing to ../alpha searching for changes no changes found + [1] $ cd .. $ cd alpha $ hgph @@ -555,6 +557,7 @@ pushing to ../alpha searching for changes no changes found + [1] $ hgph o 6 public a-F - b740e3e5c05d | @@ -659,6 +662,7 @@ pushing to ../alpha searching for changes no changes found + [1] $ hgph o 9 public a-H - 967b449fbc94 | @@ -932,6 +936,7 @@ pushing to http://localhost:$HGPORT/ searching for changes no changes found + [1] $ hg phase f54f1bb90ff3 2: draft
--- a/tests/test-phases.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-phases.t Mon Jan 30 14:14:18 2012 -0600 @@ -42,7 +42,7 @@ Test creating changeset as secret - $ mkcommit E --config phases.new-commit=2 + $ mkcommit E --config phases.new-commit='secret' $ hglog 4 2 E 3 1 D
--- a/tests/test-push-warn.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-push-warn.t Mon Jan 30 14:14:18 2012 -0600 @@ -116,6 +116,7 @@ pushing to ../c searching for changes no changes found + [1] $ hg push -r 3 ../c pushing to ../c
--- a/tests/test-ssh.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-ssh.t Mon Jan 30 14:14:18 2012 -0600 @@ -185,6 +185,7 @@ searching for changes no changes found updating bookmark foo + [1] $ hg book -d foo $ hg in -B comparing with ssh://user@dummy/remote
--- a/tests/test-subrepo-relative-path.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-subrepo-relative-path.t Mon Jan 30 14:14:18 2012 -0600 @@ -96,6 +96,7 @@ no changes found searching for changes no changes found + [1] $ cat dummylog Got arguments 1:user@dummy 2:hg -R cloned serve --stdio
--- a/tests/test-treediscovery-legacy.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-treediscovery-legacy.t Mon Jan 30 14:14:18 2012 -0600 @@ -51,6 +51,7 @@ $ hg push -R empty1 $remote pushing to http://localhost:$HGPORT/ no changes found + [1] $ tstop Base repo: @@ -110,6 +111,7 @@ pushing to http://localhost:$HGPORT/ searching for changes no changes found + [1] $ cd .. Local is empty: @@ -140,6 +142,7 @@ $ hg push $remote pushing to http://localhost:$HGPORT/ no changes found + [1] $ hg pull $remote pulling from http://localhost:$HGPORT/ requesting all changes @@ -184,6 +187,7 @@ pushing to http://localhost:$HGPORT/ searching for changes no changes found + [1] $ hg pull $remote pulling from http://localhost:$HGPORT/ searching for changes
--- a/tests/test-treediscovery.t Mon Jan 30 16:28:27 2012 +0100 +++ b/tests/test-treediscovery.t Mon Jan 30 14:14:18 2012 -0600 @@ -45,6 +45,7 @@ $ hg push -R empty1 $remote pushing to http://localhost:$HGPORT/ no changes found + [1] $ tstop Base repo: @@ -104,6 +105,7 @@ pushing to http://localhost:$HGPORT/ searching for changes no changes found + [1] $ cd .. Local is empty: @@ -130,6 +132,7 @@ $ hg push $remote pushing to http://localhost:$HGPORT/ no changes found + [1] $ hg pull $remote pulling from http://localhost:$HGPORT/ requesting all changes @@ -172,6 +175,7 @@ pushing to http://localhost:$HGPORT/ searching for changes no changes found + [1] $ hg pull $remote pulling from http://localhost:$HGPORT/ searching for changes