infinitepush: drop the wrapping of update command on client side
authorPulkit Goyal <7895pulkit@gmail.com>
Wed, 21 Mar 2018 19:23:10 +0530
changeset 37202 95cc57a74363
parent 37201 aa015dd92591
child 37203 f083e7fd6313
infinitepush: drop the wrapping of update command on client side The extension wraps update command to client side to add functionality to pull and checkout to a revision if it does not present locally. There is a twist to that, only changesets which can resolve to remotenames can be pulled using this. Differential Revision: https://phab.mercurial-scm.org/D2954
hgext/infinitepush/__init__.py
tests/test-infinitepush.t
--- a/hgext/infinitepush/__init__.py	Fri Mar 30 12:49:50 2018 -0700
+++ b/hgext/infinitepush/__init__.py	Wed Mar 21 19:23:10 2018 +0530
@@ -91,7 +91,6 @@
 import re
 import socket
 import subprocess
-import sys
 import tempfile
 import time
 
@@ -312,7 +311,6 @@
          _('force push to go to bundle store (EXPERIMENTAL)')))
 
     extensions.wrapcommand(commands.table, 'pull', _pull)
-    extensions.wrapcommand(commands.table, 'update', _update)
 
     extensions.wrapfunction(discovery, 'checkheads', _checkheads)
 
@@ -577,39 +575,6 @@
                     return "%s %s\n" % (0, r)
     return _lookup
 
-def _update(orig, ui, repo, node=None, rev=None, **opts):
-    if rev and node:
-        raise error.Abort(_("please specify just one revision"))
-
-    if not opts.get('date') and (rev or node) not in repo:
-        mayberemote = rev or node
-        mayberemote = _tryhoist(ui, mayberemote)
-        dopull = False
-        kwargs = {}
-        if _scratchbranchmatcher(mayberemote):
-            dopull = True
-            kwargs['bookmark'] = [mayberemote]
-        elif len(mayberemote) == 40 and _maybehash(mayberemote):
-            dopull = True
-            kwargs['rev'] = [mayberemote]
-
-        if dopull:
-            ui.warn(
-                _("'%s' does not exist locally - looking for it " +
-                  "remotely...\n") % mayberemote)
-            # Try pulling node from remote repo
-            try:
-                cmdname = '^pull'
-                pullcmd = commands.table[cmdname][0]
-                pullopts = dict(opt[1:3] for opt in commands.table[cmdname][1])
-                pullopts.update(kwargs)
-                pullcmd(ui, repo, **pullopts)
-            except Exception:
-                ui.warn(_('pull failed: %s\n') % sys.exc_info()[1])
-            else:
-                ui.warn(_("'%s' found remotely\n") % mayberemote)
-    return orig(ui, repo, node, rev, **opts)
-
 def _pull(orig, ui, repo, source="default", **opts):
     # Copy paste from `pull` command
     source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
--- a/tests/test-infinitepush.t	Fri Mar 30 12:49:50 2018 -0700
+++ b/tests/test-infinitepush.t	Wed Mar 21 19:23:10 2018 +0530
@@ -165,49 +165,3 @@
   (run 'hg heads .' to see heads, 'hg merge' to merge)
   $ hg log -r scratch/scratchontopofpublic -T '{phase}'
   draft (no-eol)
-Strip scratchontopofpublic commit and do hg update
-  $ hg log -r tip -T '{node}\n'
-  c70aee6da07d7cdb9897375473690df3a8563339
-  $ echo "[extensions]" >> .hg/hgrc
-  $ echo "strip=" >> .hg/hgrc
-  $ hg strip -q tip
-  $ hg up c70aee6da07d7cdb9897375473690df3a8563339
-  'c70aee6da07d7cdb9897375473690df3a8563339' does not exist locally - looking for it remotely...
-  pulling from ssh://user@dummy/repo
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 1 files
-  new changesets c70aee6da07d
-  (run 'hg update' to get a working copy)
-  'c70aee6da07d7cdb9897375473690df3a8563339' found remotely
-  2 files updated, 0 files merged, 2 files removed, 0 files unresolved
-
-Trying to pull from bad path
-  $ hg strip -q tip
-  $ hg --config paths.default=badpath up c70aee6da07d7cdb9897375473690df3a8563339
-  'c70aee6da07d7cdb9897375473690df3a8563339' does not exist locally - looking for it remotely...
-  pulling from $TESTTMP/client2/badpath (glob)
-  pull failed: repository $TESTTMP/client2/badpath not found
-  abort: unknown revision 'c70aee6da07d7cdb9897375473690df3a8563339'!
-  [255]
-
-Strip commit and pull it using hg update with bookmark name
-  $ hg strip -q d8fde0ddfc96
-  $ hg book -d scratch/mybranch
-  $ hg up scratch/mybranch
-  'scratch/mybranch' does not exist locally - looking for it remotely...
-  pulling from ssh://user@dummy/repo
-  searching for changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 2 files
-  new changesets d8fde0ddfc96
-  (run 'hg update' to get a working copy)
-  'scratch/mybranch' found remotely
-  2 files updated, 0 files merged, 1 files removed, 0 files unresolved
-  (activating bookmark scratch/mybranch)
-  $ hg log -r scratch/mybranch -T '{node}'
-  d8fde0ddfc962183977f92d2bc52d303b8840f9d (no-eol)