Patchwork [dead-code?] sshserver: drop ancient do_{lock, unlock, addchangegroup} methods

login
register
mail settings
Submitter Augie Fackler
Date June 29, 2015, 9:21 p.m.
Message ID <03b7ba2866bbdf465f13.1435612883@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/9818/
State Accepted
Headers show

Comments

Augie Fackler - June 29, 2015, 9:21 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1435612236 14400
#      Mon Jun 29 17:10:36 2015 -0400
# Node ID 03b7ba2866bbdf465f13addeb9f720de3f9ee2d6
# Parent  5d0847cd158741975598a29eedad1327af41fd1f
sshserver: drop ancient do_{lock,unlock,addchangegroup} methods

These were marked as deprecated and dangerous way back in
e8c4f3d3df8c, which was first included in Mercurial 0.9.1. While it's
possible that clients from that long ago are still around somewhere,
they're risky for servers in that they want to lock the repo, and then
might leave it locked if they died before finishing their transaction.

Given that it's been 9 years, let's go ahead and cut this last
lingering tie with a basically-untested protocol.
Matt Mackall - July 1, 2015, 7:17 p.m.
On Mon, 2015-06-29 at 17:21 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1435612236 14400
> #      Mon Jun 29 17:10:36 2015 -0400
> # Node ID 03b7ba2866bbdf465f13addeb9f720de3f9ee2d6
> # Parent  5d0847cd158741975598a29eedad1327af41fd1f
> sshserver: drop ancient do_{lock,unlock,addchangegroup} methods

Queued for default, thanks.

Patch

diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py
--- a/mercurial/sshserver.py
+++ b/mercurial/sshserver.py
@@ -6,7 +6,7 @@ 
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import util, hook, wireproto, changegroup
+import util, hook, wireproto
 import os, sys
 
 class sshserver(wireproto.abstractserverproto):
@@ -120,33 +120,6 @@  class sshserver(wireproto.abstractserver
             else: self.sendresponse("")
         return cmd != ''
 
-    def do_lock(self):
-        '''DEPRECATED - allowing remote client to lock repo is not safe'''
-
-        self.lock = self.repo.lock()
-        return ""
-
-    def do_unlock(self):
-        '''DEPRECATED'''
-
-        if self.lock:
-            self.lock.release()
-        self.lock = None
-        return ""
-
-    def do_addchangegroup(self):
-        '''DEPRECATED'''
-
-        if not self.lock:
-            self.sendresponse("not locked")
-            return
-
-        self.sendresponse("")
-        cg = changegroup.cg1unpacker(self.fin, "UN")
-        r = changegroup.addchangegroup(self.repo, cg, 'serve', self._client())
-        self.lock.release()
-        return str(r)
-
     def _client(self):
         client = os.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
         return 'remote:ssh:' + client
diff --git a/tests/test-hup.t b/tests/test-hup.t
deleted file mode 100644
--- a/tests/test-hup.t
+++ /dev/null
@@ -1,47 +0,0 @@ 
-#require serve fifo
-
-Test hangup signal in the middle of transaction
-
-  $ hg init
-  $ mkfifo p
-  $ hg serve --stdio < p 1>out 2>&1 &
-  $ P=$!
-
-Do test while holding fifo open
-
-  $ (
-  > echo lock
-  > echo addchangegroup
-  > start=`date +%s`
-  > # 10 second seems much enough to let the server catch up
-  > deadline=`expr $start + 10`
-  > while [ ! -s .hg/store/journal ]; do
-  >     sleep 0;
-  >     if [ `date +%s` -gt $deadline ]; then
-  >         echo "transaction did not start after 10 seconds" >&2;
-  >         exit 1;
-  >     fi
-  > done
-  > kill -HUP $P
-  > ) > p
-
-  $ wait
-  $ cat out
-  0
-  0
-  adding changesets
-  transaction abort!
-  rollback completed
-  killed!
-
-  $ ls -1d .hg/* .hg/store/*
-  .hg/00changelog.i
-  .hg/journal.bookmarks
-  .hg/journal.branch
-  .hg/journal.desc
-  .hg/journal.dirstate
-  .hg/requires
-  .hg/store
-  .hg/store/00changelog.i
-  .hg/store/00changelog.i.a
-  .hg/store/journal.phaseroots