Aaron Maenpaa avatar Aaron Maenpaa committed 589e6ab

Add a tag '<repo>' as a synonym for '<repo>/default'.

I find myself running ``hg up -C <repo>/default`` a lot. Furthermore,
I probably run ``hg up -C <repo>`` and get an error more often than
I actually specify a branch other than default. Consequently, it really
feels like I want to be able to run ``hg up -C ``<repo>`` and have that
bring me to '<repo>/default'.

Including the alias is configured using the "alias.default" option in the
[remotebranches] section and defaults to off. Furthermore, it doesn't
create an alias for the "default" remote since that leads confusion with the
default branch.

Comments (0)

Files changed (2)

hg_remotebranches.py

             for branch, nodes in bm.iteritems():
                 for n in nodes:
                     f.write('%s %s/%s\n' % (node.hex(n), remote, branch))
+                    alias_default = ui.configbool('remotebranches', 'alias.default')
+                    if remote != 'default' and branch == 'default' and alias_default:
+                        f.write('%s %s\n' % (node.hex(n), remote))
                 real[branch] = [node.hex(x) for x in nodes]
             f.close()
 

tests/test-remotebranches-with-aliases.t

+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > remotebranches=$(echo $(dirname $TESTDIR))/hg_remotebranches.py 
+  > [remotebranches]
+  > alias.default = True
+  > EOF
+
+  $ FILTERPWD="sed s%$PWD/%%g"
+
+  $ mkcommit () {
+  >     echo c$1 > f$1
+  >     hg add f$1
+  >     hg ci -m "$1"
+  > }
+
+  $ hg init alpha
+  $ cd alpha
+  $ mkcommit 0
+  $ mkcommit 1
+  $ hg branch stable
+  marked working directory as branch stable
+  $ mkcommit 2
+  $ cd ..
+  $ hg clone alpha beta | $FILTERPWD
+  updating to branch default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd beta
+  $ mkcommit 3
+  $ hg co -C stable
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg merge default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -m 'merged'
+  $ cd ..
+
+  $ hg init gamma
+  $ cd gamma
+
+  $ cat > .hg/hgrc <<EOF
+  > [paths]
+  > default = ../alpha
+  > beta = ../beta
+  > EOF
+
+  $ hg pull | $FILTERPWD
+  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)
+
+  $ hg pull beta | $FILTERPWD
+  pulling from 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)
+
+  $ hg co -C default
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+  $ hg branch default
+  marked working directory as branch default
+
+  $ mkcommit 4
+  $ hg merge stable
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+
+  $ hg ci -m 'merging stable'
+
+  $ hg log
+  changeset:   6:af8f9c9afd61
+  tag:         tip
+  parent:      5:e5922cca29a9
+  parent:      4:a43aa1e4a27c
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     merging stable
+  
+  changeset:   5:e5922cca29a9
+  parent:      3:5ae9f075bc64
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     4
+  
+  changeset:   4:a43aa1e4a27c
+  branch:      stable
+  tag:         beta/stable
+  parent:      2:5b35a0d5bd4d
+  parent:      3:5ae9f075bc64
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     merged
+  
+  changeset:   3:5ae9f075bc64
+  tag:         beta
+  tag:         beta/default
+  parent:      1:2b9c7234e035
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     3
+  
+  changeset:   2:5b35a0d5bd4d
+  branch:      stable
+  tag:         default/stable
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     2
+  
+  changeset:   1:2b9c7234e035
+  tag:         default/default
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     1
+  
+  changeset:   0:6cee5c8f3e5b
+  user:        test
+  date:        Thu Jan 01 00:00:00 1970 +0000
+  summary:     0
+  
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.