Patchwork [1,of,2] clone: add doctest for default destination

login
register
mail settings
Submitter Yuya Nishihara
Date March 21, 2014, 4:53 p.m.
Message ID <069bf1b821c8015596f2.1395420824@gimlet>
Download mbox | patch
Permalink /patch/4016/
State Accepted
Commit 069bf1b821c8015596f2926090cb274e4a0ee727
Headers show

Comments

Yuya Nishihara - March 21, 2014, 4:53 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1395416768 -32400
#      Sat Mar 22 00:46:08 2014 +0900
# Node ID 069bf1b821c8015596f2926090cb274e4a0ee727
# Parent  170d6d591a7dbc09bfe1b509dfd8f39991e653a9
clone: add doctest for default destination

Patch

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -123,7 +123,21 @@  def peer(uiorrepo, opts, path, create=Fa
     return _peerorrepo(rui, path, create).peer()
 
 def defaultdest(source):
-    '''return default destination of clone if none is given'''
+    '''return default destination of clone if none is given
+
+    >>> defaultdest('foo')
+    'foo'
+    >>> defaultdest('/foo/bar')
+    'bar'
+    >>> defaultdest('/')
+    ''
+    >>> defaultdest('')
+    '.'
+    >>> defaultdest('http://example.org/')
+    '.'
+    >>> defaultdest('http://example.org/foo/')
+    'foo'
+    '''
     return os.path.basename(os.path.normpath(util.url(source).path or ''))
 
 def share(ui, source, dest=None, update=True):
diff --git a/tests/test-doctest.py b/tests/test-doctest.py
--- a/tests/test-doctest.py
+++ b/tests/test-doctest.py
@@ -15,6 +15,7 @@  testmod('mercurial.changelog')
 testmod('mercurial.dagparser', optionflags=doctest.NORMALIZE_WHITESPACE)
 testmod('mercurial.dispatch')
 testmod('mercurial.encoding')
+testmod('mercurial.hg')
 testmod('mercurial.hgweb.hgwebdir_mod')
 testmod('mercurial.match')
 testmod('mercurial.minirst')