Patchwork D2954: infinitepush: drop the wrapping of update command on client side

login
register
mail settings
Submitter phabricator
Date March 27, 2018, 12:37 p.m.
Message ID <differential-rev-PHID-DREV-2rxhvv7of4e6fn5du3fy-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/29903/
State Superseded
Headers show

Comments

phabricator - March 27, 2018, 12:37 p.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2954

AFFECTED FILES
  hgext/infinitepush/__init__.py
  tests/test-infinitepush.t

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-infinitepush.t b/tests/test-infinitepush.t
--- a/tests/test-infinitepush.t
+++ b/tests/test-infinitepush.t
@@ -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)
diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py
--- a/hgext/infinitepush/__init__.py
+++ b/hgext/infinitepush/__init__.py
@@ -91,7 +91,6 @@ 
 import re
 import socket
 import subprocess
-import sys
 import tempfile
 import time
 
@@ -314,7 +313,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)
 
@@ -579,39 +577,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'))