changeset 5222:cbe6e263357b

parseurl: also return the revision after the "#"; add a test
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Mon, 27 Aug 2007 01:44:35 -0300
parents 8ede77c2d008
children fe55e3d6dc0b
files mercurial/cmdutil.py mercurial/commands.py mercurial/hg.py tests/test-url-rev tests/test-url-rev.out
diffstat 5 files changed, 130 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Mon Aug 27 01:44:35 2007 -0300
+++ b/mercurial/cmdutil.py	Mon Aug 27 01:44:35 2007 -0300
@@ -462,10 +462,10 @@
     '''parse url#branch, returning url, branch + revs'''
 
     if '#' not in url:
-        return url, (revs or None)
+        return url, (revs or None), None
 
     url, rev = url.split('#', 1)
-    return url, revs + [rev]
+    return url, revs + [rev], rev
 
 def revpair(repo, revs):
     '''return pair of nodes, given list of revisions. second item can
--- a/mercurial/commands.py	Mon Aug 27 01:44:35 2007 -0300
+++ b/mercurial/commands.py	Mon Aug 27 01:44:35 2007 -0300
@@ -324,7 +324,7 @@
                         visit.append(p)
     else:
         cmdutil.setremoteconfig(ui, opts)
-        dest, revs = cmdutil.parseurl(
+        dest, revs, checkout = cmdutil.parseurl(
             ui.expandpath(dest or 'default-push', dest or 'default'), revs)
         other = hg.repository(ui, dest)
         o = repo.findoutgoing(other, force=opts['force'])
@@ -1491,7 +1491,7 @@
     output = []
 
     if source:
-        source, revs = cmdutil.parseurl(ui.expandpath(source), [])
+        source, revs, checkout = cmdutil.parseurl(ui.expandpath(source), [])
         srepo = hg.repository(ui, source)
         if not rev and revs:
             rev = revs[0]
@@ -1649,7 +1649,8 @@
 
     See pull for valid source format details.
     """
-    source, revs = cmdutil.parseurl(ui.expandpath(source), opts['rev'])
+    source, revs, checkout = cmdutil.parseurl(ui.expandpath(source),
+                                              opts['rev'])
     cmdutil.setremoteconfig(ui, opts)
 
     other = hg.repository(ui, source)
@@ -1952,7 +1953,7 @@
 
     See pull for valid destination format details.
     """
-    dest, revs = cmdutil.parseurl(
+    dest, revs, checkout = cmdutil.parseurl(
         ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
     cmdutil.setremoteconfig(ui, opts)
     if revs:
@@ -2074,7 +2075,8 @@
       Alternatively specify "ssh -C" as your ssh command in your hgrc or
       with the --ssh command line option.
     """
-    source, revs = cmdutil.parseurl(ui.expandpath(source), opts['rev'])
+    source, revs, checkout = cmdutil.parseurl(ui.expandpath(source),
+                                              opts['rev'])
     cmdutil.setremoteconfig(ui, opts)
 
     other = hg.repository(ui, source)
@@ -2119,7 +2121,7 @@
     Pushing to http:// and https:// URLs is only possible, if this
     feature is explicitly enabled on the remote Mercurial server.
     """
-    dest, revs = cmdutil.parseurl(
+    dest, revs, checkout = cmdutil.parseurl(
         ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
     cmdutil.setremoteconfig(ui, opts)
 
--- a/mercurial/hg.py	Mon Aug 27 01:44:35 2007 -0300
+++ b/mercurial/hg.py	Mon Aug 27 01:44:35 2007 -0300
@@ -99,7 +99,7 @@
     """
 
     origsource = source
-    source, rev = cmdutil.parseurl(ui.expandpath(source), rev)
+    source, rev, checkout = cmdutil.parseurl(ui.expandpath(source), rev)
 
     if isinstance(source, str):
         src_repo = repository(ui, source)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-url-rev	Mon Aug 27 01:44:35 2007 -0300
@@ -0,0 +1,50 @@
+#!/bin/sh
+# test basic functionality of url#rev syntax
+
+hg init repo
+cd repo
+echo a > a
+hg ci -qAm 'add a' -d '0 0'
+hg branch foo
+echo >> a
+hg ci -m 'change a' -d '0 0'
+cd ..
+
+echo '% clone repo#foo'
+hg clone 'repo#foo' clone
+hg --cwd clone heads
+sed -e 's/default.*#/default = #/' clone/.hg/hgrc
+echo
+
+echo '% changing original repo'
+cd repo
+echo >> a
+hg ci -m 'new head of branch foo' -d '0 0'
+hg up -qC default
+echo bar > bar
+hg ci -qAm 'add bar' -d '0 0'
+hg log
+echo
+
+echo '% outgoing'
+hg -q outgoing '../clone#foo'
+echo
+
+echo '% push'
+hg -q push '../clone#foo'
+hg --cwd ../clone heads
+cd ..
+echo
+
+echo '% rolling back'
+cd clone
+hg rollback
+
+echo '% incoming'
+hg -q incoming
+
+echo '% pull'
+hg -q pull
+hg heads
+echo
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-url-rev.out	Mon Aug 27 01:44:35 2007 -0300
@@ -0,0 +1,69 @@
+marked working directory as branch foo
+% clone repo#foo
+requesting all changes
+adding changesets
+adding manifests
+adding file changes
+added 2 changesets with 2 changes to 1 files
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+changeset:   1:cd2a86ecc814
+branch:      foo
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     change a
+
+[paths]
+default = #foo
+
+% changing original repo
+changeset:   3:4cd725637392
+tag:         tip
+parent:      0:1f0dee641bb7
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     add bar
+
+changeset:   2:faba9097cad4
+branch:      foo
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     new head of branch foo
+
+changeset:   1:cd2a86ecc814
+branch:      foo
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     change a
+
+changeset:   0:1f0dee641bb7
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     add a
+
+
+% outgoing
+2:faba9097cad4
+
+% push
+changeset:   2:faba9097cad4
+branch:      foo
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     new head of branch foo
+
+
+% rolling back
+rolling back last transaction
+% incoming
+2:faba9097cad4
+% pull
+changeset:   2:faba9097cad4
+branch:      foo
+tag:         tip
+user:        test
+date:        Thu Jan 01 00:00:00 1970 +0000
+summary:     new head of branch foo
+
+