git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 7/9] remote-hg: use python urlparse

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 25, 2013, 11:20 UTC
Message-ID
<1366888849-19607-8-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1366888849-19607-1-git-send-email-felipe.contreras@gmail.com>
It's simpler, and we don't need to depend on certain Mercurial versions.
Also, now we don't update the URL if 'file://' is not present.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-hg | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 99abda4..67c3074 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -12,7 +12,7 @@
 # For remote repositories a local clone is stored in
 # "$GIT_DIR/hg/origin/clone/.hg/".
 
-from mercurial import hg, ui, bookmarks, context, util, encoding, node, error
+from mercurial import hg, ui, bookmarks, context, encoding, node, error
 
 import re
 import sys
@@ -22,7 +22,7 @@ import shutil
 import subprocess
 import urllib
 import atexit
-import hashlib
+import urlparse, hashlib
 
 #
 # If you want to switch to hg-git compatibility mode:
@@ -788,11 +788,11 @@ def do_export(parser):
     print
 
 def fix_path(alias, repo, orig_url):
-    repo_url = util.url(repo.url())
-    url = util.url(orig_url)
-    if str(url) == str(repo_url):
+    url = urlparse.urlparse(orig_url, 'file')
+    if url.scheme != 'file' or os.path.isabs(url.path):
         return
-    cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % repo_url]
+    abs_url = urlparse.urljoin("%s/" % os.getcwd(), orig_url)
+    cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % abs_url]
     subprocess.call(cmd)
 
 def main(args):
-- 
1.8.2.1
Previous: Felipe ContrerasNext: Felipe Contreras
Message 47 of 49 in “remote-helpers: fixes and cleanups”
  1. 0/9 remote-helpers: fixes and cleanupsFelipe Contreras, Apr 25, 2013
  2. 1/9 remote-bzr: trivial cleanupsFelipe Contreras, Apr 25, 2013
  3. Ramkumar RamachandraApr 25, 2013
  4. Felipe ContrerasApr 25, 2013
  5. Thomas RastApr 25, 2013
  6. Felipe ContrerasApr 25, 2013
  7. Junio C HamanoApr 25, 2013
  8. Felipe ContrerasApr 25, 2013
  9. Junio C HamanoApr 25, 2013
  10. Felipe ContrerasApr 25, 2013
  11. Junio C HamanoApr 25, 2013
  12. Felipe ContrerasApr 25, 2013
  13. Junio C HamanoApr 25, 2013
  14. Felipe ContrerasApr 26, 2013
  15. Ramkumar RamachandraApr 26, 2013
  16. Felipe ContrerasApr 26, 2013
  17. Ramkumar RamachandraApr 26, 2013
  18. Felipe ContrerasApr 26, 2013
  19. Ramkumar RamachandraApr 26, 2013
  20. Felipe ContrerasApr 26, 2013
  21. Junio C HamanoApr 26, 2013
  22. Felipe ContrerasApr 26, 2013
  23. Ramkumar RamachandraApr 26, 2013
  24. Ramkumar RamachandraApr 26, 2013
  25. Felipe ContrerasApr 26, 2013
  26. Ramkumar RamachandraApr 26, 2013
  27. Ramkumar RamachandraApr 26, 2013
  28. Felipe ContrerasApr 26, 2013
  29. Ramkumar RamachandraApr 26, 2013
  30. Felipe ContrerasApr 26, 2013
  31. Ramkumar RamachandraApr 26, 2013
  32. Felipe ContrerasApr 26, 2013
  33. Felipe ContrerasApr 26, 2013
  34. Ramkumar RamachandraApr 26, 2013
  35. Felipe ContrerasApr 26, 2013
  36. Stefano LattariniApr 25, 2013
  37. Felipe ContrerasApr 25, 2013
  38. 2/9 remote-hg: remove extra checkFelipe Contreras, Apr 25, 2013
  39. Ramkumar RamachandraApr 25, 2013
  40. Felipe ContrerasApr 25, 2013
  41. 3/9 remote-bzr: fix bad state issueFelipe Contreras, Apr 25, 2013
  42. 4/9 remote-bzr: add support to push URLsFelipe Contreras, Apr 25, 2013
  43. 5/9 remote-hg: use hashlib instead of hg sha1 utilFelipe Contreras, Apr 25, 2013
  44. Ramkumar RamachandraApr 25, 2013
  45. Felipe ContrerasApr 25, 2013
  46. 6/9 remote-bzr: store converted URLFelipe Contreras, Apr 25, 2013
  47. 7/9 remote-hg: use python urlparseFelipe Contreras, Apr 25, 2013
  48. 8/9 remote-bzr: tell bazaar to be quietFelipe Contreras, Apr 25, 2013
  49. 9/9 remote-bzr: strip extra newlineFelipe Contreras, Apr 25, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.