mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
push: fix case where remote has other named revs
This commit is contained in:
parent
292efab5ea
commit
01676b6bb9
@ -48,7 +48,10 @@ def pullremotenames(repo, remote):
|
||||
bmap = {}
|
||||
repo = repo.unfiltered()
|
||||
for branch, nodes in remote.branchmap().iteritems():
|
||||
bmap[branch] = [n for n in nodes if not repo[n].obsolete()]
|
||||
bmap[branch] = []
|
||||
for node in nodes:
|
||||
if node in repo and not repo[node].obsolete():
|
||||
bmap[branch].append(node)
|
||||
saveremotenames(repo, path, bmap, remote.listkeys('bookmarks'))
|
||||
finally:
|
||||
lock.release()
|
||||
@ -353,25 +356,25 @@ def expushdiscoverybookmarks(pushop):
|
||||
rev = repo.lookup(bookmark)
|
||||
if rev in revs:
|
||||
revs.remove(rev)
|
||||
# remove heads that already have a remote bookmark
|
||||
for bookmark, node in remotemarks.iteritems():
|
||||
rev = repo.lookup(node)
|
||||
if rev in revs:
|
||||
revs.remove(rev)
|
||||
# remove heads that already advance bookmarks (old mercurial
|
||||
# behavior)
|
||||
# remove heads that advance bookmarks (old mercurial behavior)
|
||||
for bookmark, old, new in pushop.outbookmarks:
|
||||
rev = repo.lookup(new)
|
||||
if rev in revs:
|
||||
revs.remove(rev)
|
||||
|
||||
revs = [short(r) for r in revs
|
||||
if not repo[r].obsolete()
|
||||
and not repo[r].closesbranch()]
|
||||
if revs:
|
||||
anonheads = []
|
||||
knownlist = pushop.remote.known(revs)
|
||||
for node, known in zip(revs, knownlist):
|
||||
obs = repo[node].obsolete()
|
||||
closes = repo[node].closesbranch()
|
||||
if known or obs or closes:
|
||||
continue
|
||||
anonheads.append(short(node))
|
||||
|
||||
if anonheads:
|
||||
msg = _("push would create new anonymous heads (%s)")
|
||||
hint = _("use --force to override this warning")
|
||||
raise util.Abort(msg % ', '.join(sorted(revs)), hint=hint)
|
||||
raise util.Abort(msg % ', '.join(sorted(anonheads)), hint=hint)
|
||||
return ret
|
||||
|
||||
bookmark = pushop.bookmarks[0]
|
||||
|
24
tests/dummyssh
Executable file
24
tests/dummyssh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
os.chdir(os.getenv('TESTTMP'))
|
||||
|
||||
if sys.argv[1] != "user@dummy":
|
||||
sys.exit(-1)
|
||||
|
||||
os.environ["SSH_CLIENT"] = "127.0.0.1 1 2"
|
||||
|
||||
log = open("dummylog", "ab")
|
||||
log.write("Got arguments")
|
||||
for i, arg in enumerate(sys.argv[1:]):
|
||||
log.write(" %d:%s" % (i + 1, arg))
|
||||
log.write("\n")
|
||||
log.close()
|
||||
hgcmd = sys.argv[2]
|
||||
if os.name == 'nt':
|
||||
# hack to make simple unix single quote quoting work on windows
|
||||
hgcmd = hgcmd.replace("'", '"')
|
||||
r = os.system(hgcmd)
|
||||
sys.exit(bool(r))
|
@ -1,11 +1,16 @@
|
||||
Set up extension and repos
|
||||
Set up extension and repos to clone over wire protocol
|
||||
|
||||
$ echo "[phases]" >> $HGRCPATH
|
||||
$ echo "publish = False" >> $HGRCPATH
|
||||
$ echo "[extensions]" >> $HGRCPATH
|
||||
$ echo "remotenames=`dirname $TESTDIR`/remotenames.py" >> $HGRCPATH
|
||||
$ cat >> $HGRCPATH << EOF
|
||||
> [ui]
|
||||
> ssh=python "$TESTDIR/dummyssh"
|
||||
> [phases]
|
||||
> publish = False
|
||||
> [extensions]
|
||||
> remotenames=`dirname $TESTDIR`/remotenames.py
|
||||
> EOF
|
||||
$ hg init repo1
|
||||
$ hg clone repo1 repo2
|
||||
$ hg clone ssh://user@dummy/repo1 repo2
|
||||
no changes found
|
||||
updating to branch default
|
||||
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
$ cd repo2
|
||||
@ -16,7 +21,7 @@ Test that anonymous heads are disallowed by default
|
||||
$ hg add a
|
||||
$ hg commit -m a
|
||||
$ hg push
|
||||
pushing to $TESTTMP/repo1 (glob)
|
||||
pushing to ssh://user@dummy/repo1
|
||||
searching for changes
|
||||
abort: push would create new anonymous heads (cb9a9f314b8b)
|
||||
(use --force to override this warning)
|
||||
@ -25,12 +30,12 @@ Test that anonymous heads are disallowed by default
|
||||
Create a remote bookmark
|
||||
|
||||
$ hg push --to @ -f
|
||||
pushing rev cb9a9f314b8b to destination $TESTTMP/repo1 bookmark @
|
||||
pushing rev cb9a9f314b8b to destination ssh://user@dummy/repo1 bookmark @
|
||||
searching for changes
|
||||
adding changesets
|
||||
adding manifests
|
||||
adding file changes
|
||||
added 1 changesets with 1 changes to 1 files
|
||||
remote: adding changesets
|
||||
remote: adding manifests
|
||||
remote: adding file changes
|
||||
remote: added 1 changesets with 1 changes to 1 files
|
||||
exporting bookmark @
|
||||
|
||||
Test that we can still push a head that advances a remote bookmark
|
||||
@ -39,18 +44,18 @@ Test that we can still push a head that advances a remote bookmark
|
||||
$ hg commit -m b
|
||||
$ hg book @
|
||||
$ hg push
|
||||
pushing to $TESTTMP/repo1 (glob)
|
||||
pushing to ssh://user@dummy/repo1
|
||||
searching for changes
|
||||
adding changesets
|
||||
adding manifests
|
||||
adding file changes
|
||||
added 1 changesets with 1 changes to 1 files
|
||||
remote: adding changesets
|
||||
remote: adding manifests
|
||||
remote: adding file changes
|
||||
remote: added 1 changesets with 1 changes to 1 files
|
||||
updating bookmark @
|
||||
|
||||
Test --delete
|
||||
|
||||
$ hg push --delete @
|
||||
pushing to $TESTTMP/repo1 (glob)
|
||||
pushing to ssh://user@dummy/repo1
|
||||
searching for changes
|
||||
no changes found
|
||||
deleting remote bookmark @
|
||||
@ -60,7 +65,7 @@ Test that we don't get an abort if we're doing a bare push that does nothing
|
||||
|
||||
$ hg bookmark -d @
|
||||
$ hg push
|
||||
pushing to $TESTTMP/repo1 (glob)
|
||||
pushing to ssh://user@dummy/repo1
|
||||
searching for changes
|
||||
no changes found
|
||||
[1]
|
||||
@ -71,9 +76,44 @@ remote or local repo
|
||||
$ echo c >> a
|
||||
$ hg commit -m c
|
||||
$ hg push -f
|
||||
pushing to $TESTTMP/repo1 (glob)
|
||||
pushing to ssh://user@dummy/repo1
|
||||
searching for changes
|
||||
adding changesets
|
||||
adding manifests
|
||||
adding file changes
|
||||
added 1 changesets with 1 changes to 1 files
|
||||
remote: adding changesets
|
||||
remote: adding manifests
|
||||
remote: adding file changes
|
||||
remote: added 1 changesets with 1 changes to 1 files
|
||||
|
||||
|
||||
$ hg log -G -T '{rev} {node|short} {bookmarks} {remotebookmarks}\n'
|
||||
@ 2 2d95304fed5d
|
||||
|
|
||||
o 1 1846eede8b68
|
||||
|
|
||||
o 0 cb9a9f314b8b
|
||||
|
||||
$ hg bookmark foo
|
||||
$ hg push -B foo
|
||||
pushing to ssh://user@dummy/repo1
|
||||
searching for changes
|
||||
no changes found
|
||||
exporting bookmark foo
|
||||
[1]
|
||||
$ hg log -G -T '{rev} {node|short} {bookmarks} {remotebookmarks}\n'
|
||||
@ 2 2d95304fed5d foo default/foo
|
||||
|
|
||||
o 1 1846eede8b68
|
||||
|
|
||||
o 0 cb9a9f314b8b
|
||||
|
||||
$ hg boo -d foo
|
||||
$ hg --config extensions.strip= strip . -q
|
||||
$ hg log -G -T '{rev} {node|short} {bookmarks} {remotebookmarks}\n'
|
||||
@ 1 1846eede8b68
|
||||
|
|
||||
o 0 cb9a9f314b8b
|
||||
|
||||
$ hg push
|
||||
pushing to ssh://user@dummy/repo1
|
||||
searching for changes
|
||||
no changes found
|
||||
[1]
|
||||
|
Loading…
Reference in New Issue
Block a user