relink: avoid trying to lock the same repo twice stable
authorMartin Geisler <mg@lazybytes.net>
Wed, 16 Mar 2011 15:34:10 +0100
branchstable
changeset 13657 b69102740e57
parent 13651 9777df929035
child 13658 6cc306093b99
relink: avoid trying to lock the same repo twice
hgext/relink.py
tests/test-relink.t
--- a/hgext/relink.py	Mon Mar 14 21:35:31 2011 +0100
+++ b/hgext/relink.py	Wed Mar 16 15:34:10 2011 +0100
@@ -44,6 +44,10 @@
     if not src.local():
         raise util.Abort('must specify local origin repository')
     ui.status(_('relinking %s to %s\n') % (src.store.path, repo.store.path))
+    if repo.root == src.root:
+        ui.status(_('there is nothing to relink\n'))
+        return
+
     locallock = repo.lock()
     try:
         remotelock = src.lock()
--- a/tests/test-relink.t	Mon Mar 14 21:35:31 2011 +0100
+++ b/tests/test-relink.t	Wed Mar 16 15:34:10 2011 +0100
@@ -31,6 +31,12 @@
   $ echo a >> b
   $ hg ci -Am changefiles
 
+don't sit forever trying to double-lock the source repo
+
+  $ hg relink .
+  relinking $TESTTMP/repo/.hg/store to $TESTTMP/repo/.hg/store
+  there is nothing to relink
+
 Test files are read in binary mode
 
   $ python -c "file('.hg/store/data/dummy.i', 'wb').write('a\r\nb\n')"