diff --git a/infinitepush/__init__.py b/infinitepush/__init__.py --- a/infinitepush/__init__.py +++ b/infinitepush/__init__.py @@ -179,6 +179,21 @@ raise error.Abort(_('invalid log level %s') % loglevel) return numeric_loglevel +def _tryhoist(ui, remotebookmark): + '''returns a bookmarks with hoisted part removed + + Remotenames extension has a 'hoist' config that allows to use remote + bookmarks without specifying remote path. For example, 'hg update master' + works as well as 'hg update remote/master'. We want to allow the same in + infinitepush. + ''' + + if common.isremotebooksenabled(ui): + hoist = ui.config('remotenames', 'hoist', 'default') + '/' + if remotebookmark.startswith(hoist): + return remotebookmark[len(hoist):] + return remotebookmark + class bundlestore(object): def __init__(self, repo): self._repo = repo @@ -590,6 +605,7 @@ 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): @@ -602,7 +618,7 @@ if dopull: ui.warn( _("'%s' does not exist locally - looking for it " + - "remotely...\n") % mayberemote) + "remotely...\n") % mayberemote) # Try pulling node from remote repo try: cmdname = '^pull' diff --git a/tests/test-infinitepush-remotenames.t b/tests/test-infinitepush-remotenames.t --- a/tests/test-infinitepush-remotenames.t +++ b/tests/test-infinitepush-remotenames.t @@ -180,3 +180,45 @@ remote: 36667a3f76e4 newscratch $ hg book scratch/secondbranch 2:36667a3f76e4 + +Create new bookmark and try to pull it + $ mkcommit newcommittoupdate1 + $ hg push -q -r . --to scratch/branchtoupdateto1 --create + $ hg up -q ".^" + $ mkcommit newcommittoupdate2 + created new head + $ hg push -q -r . --to scratch/branchtoupdateto2 --create + $ hg up -q ".^" + $ mkcommit newcommittopull + created new head + $ hg push -q -r . --to scratch/branchtopull --create + $ cd ../client + $ hg up default/scratch/branchtoupdateto1 + 'scratch/branchtoupdateto1' 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 2 changesets with 2 changes to 2 files (+1 heads) + (run 'hg heads .' to see heads, 'hg merge' to merge) + 'scratch/branchtoupdateto1' found remotely + 2 files updated, 0 files merged, 1 files removed, 0 files unresolved + + $ cat >> $HGRCPATH << EOF + > [remotenames] + > hoist=remote + > rename.default=remote + > EOF + + $ hg up remote/scratch/branchtoupdateto2 + 'scratch/branchtoupdateto2' 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 (+1 heads) + (run 'hg heads .' to see heads, 'hg merge' to merge) + 'scratch/branchtoupdateto2' found remotely + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved