Commits

Augie Fackler  committed 1976e41

add support for schemes

  • Participants
  • Parent commits caf71f0

Comments (0)

Files changed (3)

File hg_remotebranches.py

 from mercurial import url
 from mercurial import util
 
+from hgext import schemes
 
 def reposetup(ui, repo):
     if repo.local():
                 realpath = ''
                 if 'paths' in conf:
                     for path, uri in conf['paths'].items():
+                        for s in schemes.schemes.iterkeys():
+                            if uri.startswith('%s://' % s):
+                                # TODO: refactor schemes so we don't duplicate this logic
+                                ui.note('performing schemes expansion with scheme %s\n' % s)
+                                scheme = hg.schemes[s]
+                                parts = uri.split('://', 1)[1].split('/', scheme.parts)
+                                if len(parts) > scheme.parts:
+                                    tail = parts[-1]
+                                    parts = parts[:-1]
+                                else:
+                                    tail = ''
+                                context = dict((str(i+1), v) for i, v in enumerate(parts))
+                                uri = ''.join(scheme.templater.process(scheme.url, context)) + tail
                         uri = self.ui.expandpath(uri)
                         if remote.local():
                             uri = os.path.realpath(uri)

File tests/test-remotebranches-with-schemes

+#!/bin/sh
+
+
+echo "[extensions]" >> $HGRCPATH
+echo "graphlog=" >> $HGRCPATH
+echo "schemes=" >> $HGRCPATH
+echo "remotebranches=$(echo $(dirname $(dirname $0)))/hg_remotebranches.py" >> $HGRCPATH
+
+cat >> $HGRCPATH <<EOF
+
+[schemes]
+dotdot = ../{1}
+EOF
+
+FILTERPWD="sed s%$PWD/%%g"
+
+function mkcommit()
+{
+    echo $1 > $1
+    hg add $1
+    hg ci -m "add $1"
+}
+
+hg init alpha
+cd alpha
+mkcommit a
+mkcommit b
+hg branch stable
+mkcommit c
+cd ..
+hg clone alpha beta | $FILTERPWD
+cd beta
+mkcommit d
+hg co -C stable
+hg merge default
+hg ci -m 'merged'
+cd ..
+
+hg init gamma
+cd gamma
+cat > .hg/hgrc <<EOF
+[paths]
+default = ../alpha
+alpha = ../alpha
+beta = dotdot://beta
+EOF
+hg pull | $FILTERPWD
+hg pull beta | $FILTERPWD
+hg co -C default
+hg branch default
+mkcommit e
+hg merge stable
+hg ci -m 'merging stable'
+
+echo
+echo % graph shows tags for the branch heads of each path
+hg log --graph

File tests/test-remotebranches-with-schemes.out

+marked working directory as branch stable
+updating to branch default
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+created new head
+1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+pulling from alpha
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 3 changesets with 3 changes to 3 files
+(run 'hg update' to get a working copy)
+pulling from dotdot://beta
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 2 changesets with 1 changes to 1 files
+(run 'hg update' to get a working copy)
+3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+marked working directory as branch default
+created new head
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+
+% graph shows tags for the branch heads of each path
+@    changeset:   6:ce61ec32ee23
+|\   tag:         tip
+| |  parent:      5:6d6442577283
+| |  parent:      4:8948da77173b
+| |  user:        test
+| |  date:        Thu Jan 01 00:00:00 1970 +0000
+| |  summary:     merging stable
+| |
+| o  changeset:   5:6d6442577283
+| |  parent:      3:78f83396d79e
+| |  user:        test
+| |  date:        Thu Jan 01 00:00:00 1970 +0000
+| |  summary:     add e
+| |
+o |  changeset:   4:8948da77173b
+|\|  branch:      stable
+| |  tag:         beta/stable
+| |  parent:      2:95cb4ab9fe1d
+| |  parent:      3:78f83396d79e
+| |  user:        test
+| |  date:        Thu Jan 01 00:00:00 1970 +0000
+| |  summary:     merged
+| |
+| o  changeset:   3:78f83396d79e
+| |  tag:         beta/default
+| |  parent:      1:7c3bad9141dc
+| |  user:        test
+| |  date:        Thu Jan 01 00:00:00 1970 +0000
+| |  summary:     add d
+| |
+o |  changeset:   2:95cb4ab9fe1d
+|/   branch:      stable
+|    tag:         alpha/stable
+|    user:        test
+|    date:        Thu Jan 01 00:00:00 1970 +0000
+|    summary:     add c
+|
+o  changeset:   1:7c3bad9141dc
+|  tag:         alpha/default
+|  user:        test
+|  date:        Thu Jan 01 00:00:00 1970 +0000
+|  summary:     add b
+|
+o  changeset:   0:1f0dee641bb7
+   user:        test
+   date:        Thu Jan 01 00:00:00 1970 +0000
+   summary:     add a
+