[PATCH 5 of 8] wireproto: add nonabandoned wireproto command

Martin Geisler mg at lazybytes.net
Wed Jun 1 11:42:51 CDT 2011


# HG changeset patch
# User Martin Geisler <mg at lazybytes.net>
# Date 1306923811 -7200
# Node ID 09faf6a64b54632148461ca185c000849c7cb02f
# Parent  c64031c2591a669eb251e96e9cc0b91776413187
wireproto: add nonabandoned wireproto command

Used with httprepo and sshrepo to let the server prune the list of
heads to just the non-abandoned heads.

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -159,6 +159,17 @@
             self.ui.status(_('remote: '), l)
         return ret
 
+    def nonabandoned(self, candidates, clientheads):
+        self.requirecap('getbundle', _('look up non-abandoned heads'))
+        opts = {}
+        opts['candidates'] = encodelist(candidates)
+        opts['clientheads'] = encodelist(clientheads)
+        d = self._call('nonabandoned', **opts)
+        try:
+            return decodelist(d[:-1])
+        except ValueError:
+            self._abort(error.ResponseError(_("unexpected response:"), d))
+
     def debugwireargs(self, one, two, three=None, four=None, five=None):
         # don't pass optional arguments left at their default value
         opts = {}
@@ -291,6 +302,11 @@
 def known(repo, proto, nodes, others):
     return ''.join(b and "1" or "0" for b in repo.known(decodelist(nodes)))
 
+def nonabandoned(repo, proto, candidates, clientheads, others):
+    heads = repo.nonabandoned(decodelist(candidates),
+                              decodelist(clientheads))
+    return encodelist(heads) + '\n'
+
 def pushkey(repo, proto, namespace, key, old, new):
     # compatibility with pre-1.8 clients which were accidentally
     # sending raw binary nodes rather than utf-8-encoded hex
@@ -415,6 +431,7 @@
     'known': (known, 'nodes *'),
     'listkeys': (listkeys, 'namespace'),
     'lookup': (lookup, 'key'),
+    'nonabandoned': (nonabandoned, 'candidates clientheads *'),
     'pushkey': (pushkey, 'namespace key old new'),
     'stream_out': (stream, ''),
     'unbundle': (unbundle, 'heads'),
diff --git a/tests/test-abandoned-http.t b/tests/test-abandoned-http.t
new file mode 100644
--- /dev/null
+++ b/tests/test-abandoned-http.t
@@ -0,0 +1,98 @@
+setting up
+
+  $ cat >> $HGRCPATH <<EOF
+  > [ui]
+  > logtemplate = '{rev} {node|short} {desc|firstline|strip}\n'
+  > [defaults]
+  > abandon = -d "0 0"
+  > [extensions]
+  > graphlog =
+  > EOF
+
+  $ hg init repo
+  $ cd repo
+  $ touch i x
+  $ hg commit -A -m init i
+  $ hg commit -A -m x x
+  $ hg glog
+  @  1 0b00c28422ee x
+  |
+  o  0 54dbcd775ef0 init
+  
+  $ hg init ../empty
+  $ hg clone -q -r 0 . ../base-i
+  $ hg clone -q -r 1 . ../base-x
+
+abandon x
+
+  $ hg abandon 1::
+  $ hg glog
+  o  2 339976ff5010 abandoned
+  |
+  @  1 0b00c28422ee x
+  |
+  o  0 54dbcd775ef0 init
+  
+
+outgoing and push against empty repository
+==========================================
+
+  $ cd ../empty
+  $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log \
+  >          --config 'web.push_ssl=No' --config 'web.allow_push=*'
+  $ cat hg.pid >> $DAEMON_PIDS
+  $ cd ../repo
+
+hg outgoing
+-----------
+
+testing outgoing with no shared abandoned changesets
+
+  $ hg out http://localhost:$HGPORT/
+  comparing with http://localhost:$HGPORT/
+  searching for changes
+  0 54dbcd775ef0 init
+
+testing outgoing --abandoned with no shared abandoned changesets
+
+  $ hg out --abandoned http://localhost:$HGPORT/
+  comparing with http://localhost:$HGPORT/
+  searching for changes
+  0 54dbcd775ef0 init
+  1 0b00c28422ee x
+  2 339976ff5010 abandoned
+
+hg push
+=======
+
+testing push with no shared abandoned changesets
+
+  $ hg push http://localhost:$HGPORT/
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  $ hg -R ../empty log --abandoned
+  0 54dbcd775ef0 init
+  $ hg -R ../empty rollback -q
+
+testing push --abandoned with no shared abandoned changesets
+
+  $ hg push --abandoned http://localhost:$HGPORT/
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 3 changesets with 2 changes to 2 files
+  $ hg -R ../empty log --abandoned
+  2 339976ff5010 abandoned
+  1 0b00c28422ee x
+  0 54dbcd775ef0 init
+  $ hg -R ../empty rollback -q
+
+error log
+
+  $ cat ../empty/errors.log
diff --git a/tests/test-abandoned.t b/tests/test-abandoned.t
--- a/tests/test-abandoned.t
+++ b/tests/test-abandoned.t
@@ -3,6 +3,7 @@
   $ cat >> $HGRCPATH <<EOF
   > [ui]
   > logtemplate = '{rev} {node|short} {desc|firstline|strip}\n'
+  > ssh = python $TESTDIR/dummyssh
   > [defaults]
   > abandon = -d "0 0"
   > [extensions]
@@ -65,12 +66,23 @@
   searching for changes
   0 54dbcd775ef0 init
 
+  $ hg out ssh://user@dummy/empty
+  comparing with ssh://user@dummy/empty
+  searching for changes
+  0 54dbcd775ef0 init
+
   $ hg out ../base-i
   comparing with ../base-i
   searching for changes
   no changes found
   [1]
 
+  $ hg out ssh://user@dummy/base-i
+  comparing with ssh://user@dummy/base-i
+  searching for changes
+  no changes found
+  [1]
+
 testing outgoing --abandoned with no shared abandoned changesets
 
   $ hg out --abandoned ../empty
@@ -80,12 +92,25 @@
   1 0b00c28422ee x
   2 339976ff5010 abandoned
 
+  $ hg out --abandoned ssh://user@dummy/empty
+  comparing with ssh://user@dummy/empty
+  searching for changes
+  0 54dbcd775ef0 init
+  1 0b00c28422ee x
+  2 339976ff5010 abandoned
+
   $ hg out --abandoned ../base-i
   comparing with ../base-i
   searching for changes
   1 0b00c28422ee x
   2 339976ff5010 abandoned
 
+  $ hg out --abandoned ssh://user@dummy/base-i
+  comparing with ssh://user@dummy/base-i
+  searching for changes
+  1 0b00c28422ee x
+  2 339976ff5010 abandoned
+
 testing outgoing with a shared abandoned changeset
 
   $ hg out ../base-x
@@ -93,11 +118,21 @@
   searching for changes
   2 339976ff5010 abandoned
 
+  $ hg out ssh://user@dummy/base-x
+  comparing with ssh://user@dummy/base-x
+  searching for changes
+  2 339976ff5010 abandoned
+
   $ hg out --abandoned ../base-x
   comparing with ../base-x
   searching for changes
   2 339976ff5010 abandoned
 
+  $ hg out --abandoned ssh://user@dummy/base-x
+  comparing with ssh://user@dummy/base-x
+  searching for changes
+  2 339976ff5010 abandoned
+
 hg push
 =======
 
@@ -114,11 +149,27 @@
   0 54dbcd775ef0 init
   $ hg -R ../empty rollback -q
 
+  $ hg push ssh://user@dummy/empty
+  pushing to ssh://user@dummy/empty
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  $ hg -R ../empty log --abandoned
+  0 54dbcd775ef0 init
+  $ hg -R ../empty rollback -q
+
   $ hg push ../base-i
   pushing to ../base-i
   searching for changes
   no changes found
 
+  $ hg push ssh://user@dummy/base-i
+  pushing to ssh://user@dummy/base-i
+  searching for changes
+  no changes found
+
 testing push --abandoned with no shared abandoned changesets
 
   $ hg push --abandoned ../empty
@@ -134,6 +185,19 @@
   0 54dbcd775ef0 init
   $ hg -R ../empty rollback -q
 
+  $ hg push --abandoned ssh://user@dummy/empty
+  pushing to ssh://user@dummy/empty
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 3 changesets with 2 changes to 2 files
+  $ hg -R ../empty log --abandoned
+  2 339976ff5010 abandoned
+  1 0b00c28422ee x
+  0 54dbcd775ef0 init
+  $ hg -R ../empty rollback -q
+
   $ hg push --abandoned ../base-i
   pushing to ../base-i
   searching for changes
@@ -162,6 +226,19 @@
   0 54dbcd775ef0 init
   $ hg -R ../base-x rollback -q
 
+  $ hg push ssh://user@dummy/base-x
+  pushing to ssh://user@dummy/base-x
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 0 changes to 0 files
+  $ hg -R ../base-x log --abandoned
+  2 339976ff5010 abandoned
+  1 0b00c28422ee x
+  0 54dbcd775ef0 init
+  $ hg -R ../base-x rollback -q
+
   $ hg push --abandoned ../base-x
   pushing to ../base-x
   searching for changes
@@ -185,6 +262,11 @@
   comparing with ../repo
   0 54dbcd775ef0 init
 
+  $ cd ../empty
+  $ hg in ssh://user@dummy/repo
+  comparing with ssh://user@dummy/repo
+  0 54dbcd775ef0 init
+
   $ cd ../base-i
   $ hg in ../repo
   comparing with ../repo
@@ -192,6 +274,13 @@
   no changes found
   [1]
 
+  $ cd ../base-i
+  $ hg in ssh://user@dummy/repo
+  comparing with ssh://user@dummy/repo
+  searching for changes
+  no changes found
+  [1]
+
 testing incoming --abandoned with no shared abandoned changesets
 
   $ cd ../empty
@@ -201,6 +290,12 @@
   1 0b00c28422ee x
   2 339976ff5010 abandoned
 
+  $ hg in --abandoned ssh://user@dummy/repo
+  comparing with ssh://user@dummy/repo
+  0 54dbcd775ef0 init
+  1 0b00c28422ee x
+  2 339976ff5010 abandoned
+
   $ cd ../base-i
   $ hg in --abandoned ../repo
   comparing with ../repo
@@ -208,6 +303,12 @@
   1 0b00c28422ee x
   2 339976ff5010 abandoned
 
+  $ hg in --abandoned ssh://user@dummy/repo
+  comparing with ssh://user@dummy/repo
+  searching for changes
+  1 0b00c28422ee x
+  2 339976ff5010 abandoned
+
 testing incoming with a shared abandoned changeset
 
   $ cd ../base-x
diff --git a/tests/test-debugcomplete.t b/tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t
+++ b/tests/test-debugcomplete.t
@@ -197,8 +197,8 @@
   init: ssh, remotecmd, insecure
   log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, abandoned, patch, git, limit, no-merges, stat, style, template, include, exclude
   merge: force, tool, rev, preview
-  pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure
-  push: force, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
+  pull: update, force, abandoned, rev, bookmark, branch, ssh, remotecmd, insecure
+  push: force, abandoned, rev, bookmark, branch, new-branch, ssh, remotecmd, insecure
   remove: after, force, include, exclude
   serve: accesslog, daemon, daemon-pipefds, errorlog, port, address, prefix, name, web-conf, webdir-conf, pid-file, stdio, templates, style, ipv6, certificate
   status: all, modified, added, removed, deleted, clean, unknown, ignored, no-status, copies, print0, rev, change, include, exclude, subrepos
@@ -247,10 +247,10 @@
   help: extension, command
   identify: rev, num, id, branch, tags, bookmarks
   import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
-  incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
+  incoming: force, abandoned, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
   locate: rev, print0, fullpath, include, exclude
   manifest: rev, all
-  outgoing: force, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
+  outgoing: force, abandoned, rev, newest-first, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
   parents: rev, style, template
   paths: 
   recover: 
diff --git a/tests/test-http-proxy.t b/tests/test-http-proxy.t
--- a/tests/test-http-proxy.t
+++ b/tests/test-http-proxy.t
@@ -103,18 +103,22 @@
   * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
+  * - - [*] "GET http://localhost:$HGPORT/?cmd=nonabandoned HTTP/1.1" - - x-hgarg-1:candidates=83180e7845de420a1bb46896fd5fe05294f8d629&clientheads=0000000000000000000000000000000000000000 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
+  * - - [*] "GET http://localhost:$HGPORT/?cmd=nonabandoned HTTP/1.1" - - x-hgarg-1:candidates=83180e7845de420a1bb46896fd5fe05294f8d629&clientheads=0000000000000000000000000000000000000000 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
+  * - - [*] "GET http://localhost:$HGPORT/?cmd=nonabandoned HTTP/1.1" - - x-hgarg-1:candidates=83180e7845de420a1bb46896fd5fe05294f8d629&clientheads=0000000000000000000000000000000000000000 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=heads HTTP/1.1" - - (glob)
+  * - - [*] "GET http://localhost:$HGPORT/?cmd=nonabandoned HTTP/1.1" - - x-hgarg-1:candidates=83180e7845de420a1bb46896fd5fe05294f8d629&clientheads=0000000000000000000000000000000000000000 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=getbundle HTTP/1.1" - - x-hgarg-1:common=0000000000000000000000000000000000000000&heads=83180e7845de420a1bb46896fd5fe05294f8d629 (glob)
   * - - [*] "GET http://localhost:$HGPORT/?cmd=listkeys HTTP/1.1" - - x-hgarg-1:namespace=bookmarks (glob)
 
diff --git a/tests/test-schemes.t b/tests/test-schemes.t
--- a/tests/test-schemes.t
+++ b/tests/test-schemes.t
@@ -31,6 +31,7 @@
   sending heads command
   searching for changes
   all remote heads known locally
+  sending nonabandoned command
   no changes found
   [1]
 


More information about the Mercurial-devel mailing list