* [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc @ 2014-02-21 15:17 Daniel Liew 2014-03-24 15:07 ` Delcypher 2014-04-12 20:01 ` Felipe Contreras 0 siblings, 2 replies; 10+ messages in thread From: Daniel Liew @ 2014-02-21 15:17 UTC (permalink / raw) To: git; +Cc: felipe.contreras git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc Use the hgrc configuration file in the internal mercurial repository in addition to the other system wide hgrc files. This is done by using the 'ui' object from the 'repository' object which will have loaded the repository hgrc file if it exists. Prior to this patch the mercurial repository's hgrc file was ignored which I consider to be a bug. Signed-off-by: Dan Liew <delcypher@gmail.com> --- contrib/remote-helpers/git-remote-hg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg index eb89ef6..451842a 100755 --- a/contrib/remote-helpers/git-remote-hg +++ b/contrib/remote-helpers/git-remote-hg @@ -421,7 +421,7 @@ def get_repo(url, alias): repo = hg.repository(myui, local_path) try: - peer = hg.peer(myui, {}, url) + peer = hg.peer(repo._unfilteredrepo.ui, {}, url) except: die('Repository error') repo.pull(peer, heads=None, force=True) -- 1.9.0 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc 2014-02-21 15:17 [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc Daniel Liew @ 2014-03-24 15:07 ` Delcypher 2014-04-12 20:01 ` Felipe Contreras 1 sibling, 0 replies; 10+ messages in thread From: Delcypher @ 2014-03-24 15:07 UTC (permalink / raw) To: git; +Cc: Felipe Contreras ping. On 21 February 2014 15:17, Daniel Liew <delcypher@gmail.com> wrote: > git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc > > Use the hgrc configuration file in the internal mercurial repository in > addition to the other system wide hgrc files. This is done by using the > 'ui' object from the 'repository' object which will have loaded the > repository hgrc file if it exists. > > Prior to this patch the mercurial repository's hgrc file was ignored > which I consider to be a bug. > > Signed-off-by: Dan Liew <delcypher@gmail.com> > --- > contrib/remote-helpers/git-remote-hg | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/contrib/remote-helpers/git-remote-hg > b/contrib/remote-helpers/git-remote-hg > index eb89ef6..451842a 100755 > --- a/contrib/remote-helpers/git-remote-hg > +++ b/contrib/remote-helpers/git-remote-hg > @@ -421,7 +421,7 @@ def get_repo(url, alias): > > repo = hg.repository(myui, local_path) > try: > - peer = hg.peer(myui, {}, url) > + peer = hg.peer(repo._unfilteredrepo.ui, {}, url) > except: > die('Repository error') > repo.pull(peer, heads=None, force=True) > -- > 1.9.0 > > ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc 2014-02-21 15:17 [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc Daniel Liew 2014-03-24 15:07 ` Delcypher @ 2014-04-12 20:01 ` Felipe Contreras 2014-04-15 15:37 ` Delcypher 1 sibling, 1 reply; 10+ messages in thread From: Felipe Contreras @ 2014-04-12 20:01 UTC (permalink / raw) To: Daniel Liew, git; +Cc: felipe.contreras Daniel Liew wrote: > git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc > > Use the hgrc configuration file in the internal mercurial repository in > addition to the other system wide hgrc files. This is done by using the > 'ui' object from the 'repository' object which will have loaded the > repository hgrc file if it exists. What is the problem you are trying to solve? Is there a way to test that this code is working correctly? > Prior to this patch the mercurial repository's hgrc file was ignored > which I consider to be a bug. It might be, although the internal repository is not supposed to be used by the user. > Signed-off-by: Dan Liew <delcypher@gmail.com> > --- > contrib/remote-helpers/git-remote-hg | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/contrib/remote-helpers/git-remote-hg > b/contrib/remote-helpers/git-remote-hg > index eb89ef6..451842a 100755 > --- a/contrib/remote-helpers/git-remote-hg > +++ b/contrib/remote-helpers/git-remote-hg > @@ -421,7 +421,7 @@ def get_repo(url, alias): > > repo = hg.repository(myui, local_path) > try: > - peer = hg.peer(myui, {}, url) > + peer = hg.peer(repo._unfilteredrepo.ui, {}, url) Why not repo.unfiltered.ui? Or just repo.ui. Cheers. -- Felipe Contreras ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc 2014-04-12 20:01 ` Felipe Contreras @ 2014-04-15 15:37 ` Delcypher 2014-04-20 18:12 ` Felipe Contreras 0 siblings, 1 reply; 10+ messages in thread From: Delcypher @ 2014-04-15 15:37 UTC (permalink / raw) To: Felipe Contreras; +Cc: git > What is the problem you are trying to solve? The problem I was trying to solve is I wanted my authentication details to be in a hgrc local to the repository. The problem is git-remote-hg will parse ``.git/hg/origin/clone/.hg/hgrc`` but will ignore any settings in it (this seems a little silly). You can see that git-remote-hg parses this by placing invalid syntax in the file. > Is there a way to test that this > code is working correctly? The effects are much more obvious if you use a mercurial repository that uses https and then you try to push to it with authentication details in ``.git/hg/origin/clone/.hg/hgrc``. For example [auth] cc.prefix = hg.codeplex.com cc.username = USERNAME cc.password = PASSWORD cc.schemes = https pushing will fail because the authorisation details get completely ignored and you will get an exception raised with a stack trace like this... Traceback (most recent call last): File "/home/dsl11/dev/git-remote-hg/git-remote-hg", line 1254, in <module> sys.exit(main(sys.argv)) File "/home/dsl11/dev/git-remote-hg/git-remote-hg", line 1238, in main do_export(parser) File "/home/dsl11/dev/git-remote-hg/git-remote-hg", line 1119, in do_export if not push(parser.repo, peer, parsed_refs, p_revs): File "/home/dsl11/dev/git-remote-hg/git-remote-hg", line 1007, in push ret = push_unsafe(repo, remote, parsed_refs, p_revs) File "/home/dsl11/dev/git-remote-hg/git-remote-hg", line 990, in push_unsafe return remote.unbundle(cg, remoteheads, 'push') File "/usr/lib/python2.7/site-packages/mercurial/wireproto.py", line 308, in unbundle ret, output = self._callpush("unbundle", cg, heads=heads) File "/usr/lib/python2.7/site-packages/mercurial/httppeer.py", line 201, in _callpush r = self._call(cmd, data=fp, headers=headers, **args) File "/usr/lib/python2.7/site-packages/mercurial/httppeer.py", line 171, in _call fp = self._callstream(cmd, **args) File "/usr/lib/python2.7/site-packages/mercurial/httppeer.py", line 118, in _callstream resp = self.urlopener.open(req) File "/usr/lib/python2.7/urllib2.py", line 410, in open response = meth(req, response) File "/usr/lib/python2.7/urllib2.py", line 523, in http_response 'http', request, response, code, msg, hdrs) File "/usr/lib/python2.7/urllib2.py", line 442, in error result = self._call_chain(*args) File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain result = func(*args) File "/usr/lib/python2.7/urllib2.py", line 897, in http_error_401 url, req, headers) File "/usr/lib/python2.7/site-packages/mercurial/url.py", line 436, in http_error_auth_reqed self, auth_header, host, req, headers) File "/usr/lib/python2.7/urllib2.py", line 872, in http_error_auth_reqed response = self.retry_http_basic_auth(host, req, realm) File "/usr/lib/python2.7/urllib2.py", line 878, in retry_http_basic_auth user, pw = self.passwd.find_user_password(realm, host) File "/usr/lib/python2.7/site-packages/mercurial/url.py", line 36, in find_user_password raise util.Abort(_('http authorization required')) mercurial.error.Abort: http authorization required However, if you don't have a repository to hand you could also do the following to observe the settings in the repository's hgrc being respected 1. Clone a repository $ git clone hg::https://hg.codeplex.com/boogie 2. Add setting to ``.git/hg/origin/clone/.hg/hgrc`` [ui] quiet = True 3. With the current of git-remote-hg, when you do a pull you see $ git pull searching for changes no changes found Already up-to-date. You can see that "quiet" is **not** being respected. If use my patch to git-remote-hg and run again you see $ git pull Already up-to-date. which shows "quiet" being respected. >> Prior to this patch the mercurial repository's hgrc file was ignored >> which I consider to be a bug. > > It might be, although the internal repository is not supposed to be used by the > user. > >> Signed-off-by: Dan Liew <delcypher@gmail.com> >> --- >> contrib/remote-helpers/git-remote-hg | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/contrib/remote-helpers/git-remote-hg >> b/contrib/remote-helpers/git-remote-hg >> index eb89ef6..451842a 100755 >> --- a/contrib/remote-helpers/git-remote-hg >> +++ b/contrib/remote-helpers/git-remote-hg >> @@ -421,7 +421,7 @@ def get_repo(url, alias): >> >> repo = hg.repository(myui, local_path) >> try: >> - peer = hg.peer(myui, {}, url) >> + peer = hg.peer(repo._unfilteredrepo.ui, {}, url) > > Why not repo.unfiltered.ui? Or just repo.ui. using repo.unfiltered.ui makes git-remote-hg return "ERROR: Repository error" Using "repo.ui" works correctly. I simply did not know that was there because I was debugging using PyDev in Eclipse and I could only find a ui object in repo.unfiltered.ui. PyDev does not show "repo.ui" but it clearly works so using repo.ui is probably better than repo._unfilteredrepo.ui Thanks, Dan Liew. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc 2014-04-15 15:37 ` Delcypher @ 2014-04-20 18:12 ` Felipe Contreras 2014-04-20 19:57 ` Delcypher 0 siblings, 1 reply; 10+ messages in thread From: Felipe Contreras @ 2014-04-20 18:12 UTC (permalink / raw) To: Delcypher, Felipe Contreras; +Cc: git Delcypher wrote: > > What is the problem you are trying to solve? > The problem I was trying to solve is I wanted my authentication > details to be in a hgrc local to the repository. > > The problem is git-remote-hg will parse > ``.git/hg/origin/clone/.hg/hgrc`` but will ignore any settings in it > (this seems a little silly). > You can see that git-remote-hg parses this by placing invalid syntax > in the file. > > > Is there a way to test that this > > code is working correctly? > > The effects are much more obvious if you use a mercurial repository > that uses https and then you try to push to it with authentication > details in ``.git/hg/origin/clone/.hg/hgrc``. For example > > [auth] > cc.prefix = hg.codeplex.com > cc.username = USERNAME > cc.password = PASSWORD > cc.schemes = https > > pushing will fail because the authorisation details get completely > ignored and you will get an exception raised with a stack trace like > this... > > Traceback (most recent call last): > File "/home/dsl11/dev/git-remote-hg/git-remote-hg", line 1254, in <module> > sys.exit(main(sys.argv)) > File "/home/dsl11/dev/git-remote-hg/git-remote-hg", line 1238, in main > do_export(parser) > File "/home/dsl11/dev/git-remote-hg/git-remote-hg", line 1119, in do_export > if not push(parser.repo, peer, parsed_refs, p_revs): > File "/home/dsl11/dev/git-remote-hg/git-remote-hg", line 1007, in push > ret = push_unsafe(repo, remote, parsed_refs, p_revs) > File "/home/dsl11/dev/git-remote-hg/git-remote-hg", line 990, in push_unsafe > return remote.unbundle(cg, remoteheads, 'push') > File "/usr/lib/python2.7/site-packages/mercurial/wireproto.py", line > 308, in unbundle > ret, output = self._callpush("unbundle", cg, heads=heads) > File "/usr/lib/python2.7/site-packages/mercurial/httppeer.py", line > 201, in _callpush > r = self._call(cmd, data=fp, headers=headers, **args) > File "/usr/lib/python2.7/site-packages/mercurial/httppeer.py", line > 171, in _call > fp = self._callstream(cmd, **args) > File "/usr/lib/python2.7/site-packages/mercurial/httppeer.py", line > 118, in _callstream > resp = self.urlopener.open(req) > File "/usr/lib/python2.7/urllib2.py", line 410, in open > response = meth(req, response) > File "/usr/lib/python2.7/urllib2.py", line 523, in http_response > 'http', request, response, code, msg, hdrs) > File "/usr/lib/python2.7/urllib2.py", line 442, in error > result = self._call_chain(*args) > File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain > result = func(*args) > File "/usr/lib/python2.7/urllib2.py", line 897, in http_error_401 > url, req, headers) > File "/usr/lib/python2.7/site-packages/mercurial/url.py", line 436, > in http_error_auth_reqed > self, auth_header, host, req, headers) > File "/usr/lib/python2.7/urllib2.py", line 872, in http_error_auth_reqed > response = self.retry_http_basic_auth(host, req, realm) > File "/usr/lib/python2.7/urllib2.py", line 878, in retry_http_basic_auth > user, pw = self.passwd.find_user_password(realm, host) > File "/usr/lib/python2.7/site-packages/mercurial/url.py", line 36, > in find_user_password > raise util.Abort(_('http authorization required')) > mercurial.error.Abort: http authorization required > > > However, if you don't have a repository to hand you could also do the > following to observe the settings in the repository's hgrc being > respected > > 1. Clone a repository > $ git clone hg::https://hg.codeplex.com/boogie > > 2. Add setting to ``.git/hg/origin/clone/.hg/hgrc`` > > [ui] > quiet = True > > 3. With the current of git-remote-hg, when you do a pull you see > > $ git pull > searching for changes > no changes found > Already up-to-date. > > You can see that "quiet" is **not** being respected. If use my patch > to git-remote-hg and run again you see > > > $ git pull > Already up-to-date. > > which shows "quiet" being respected. This is what I get: % git pull /tmp/boogie[master] nysa searching for changes no changes found Already up-to-date. % cat > .git/hg/origin/clone/.hg/hgrc <<EOF [ui] quiet = True EOF % git pull /tmp/boogie[master] nysa Already up-to-date. So clearly there is something different on my side. What version of Mercurial are you using? -- Felipe Contreras ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc 2014-04-20 18:12 ` Felipe Contreras @ 2014-04-20 19:57 ` Delcypher 2014-04-20 19:54 ` Felipe Contreras 0 siblings, 1 reply; 10+ messages in thread From: Delcypher @ 2014-04-20 19:57 UTC (permalink / raw) To: Felipe Contreras; +Cc: git > What version of Mercurial are you using? $ hg --version Mercurial Distributed SCM (version 2.9.2) (see http://mercurial.selenic.com for more information) Copyright (C) 2005-2014 Matt Mackall and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc 2014-04-20 19:57 ` Delcypher @ 2014-04-20 19:54 ` Felipe Contreras 2014-04-20 20:36 ` Delcypher 0 siblings, 1 reply; 10+ messages in thread From: Felipe Contreras @ 2014-04-20 19:54 UTC (permalink / raw) To: Delcypher, Felipe Contreras; +Cc: git Delcypher wrote: > > What version of Mercurial are you using? > > $ hg --version > > Mercurial Distributed SCM (version 2.9.2) Same as me. And which version of git-remote-hg are you using? -- Felipe Contreras ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc 2014-04-20 19:54 ` Felipe Contreras @ 2014-04-20 20:36 ` Delcypher 2014-04-20 20:48 ` Felipe Contreras 0 siblings, 1 reply; 10+ messages in thread From: Delcypher @ 2014-04-20 20:36 UTC (permalink / raw) To: Felipe Contreras; +Cc: git > Same as me. And which version of git-remote-hg are you using? I'm using the version that ships with git 1.9.2 I've taken a look and it seems I made a mistake, sorry. It seems that [ui] quiet = True is being respected when placed in ``.git/hg/origin/clone/.hg/hgrc`` with the un patched version of git-remote-hg. But it is still the case that authentication details are being ignored when present in ``.git/hg/origin/clone/.hg/hgrc`` i.e. something like the following is ignored. [auth] cc.prefix = hg.codeplex.com cc.username = USERNAME # Eurgh fixme this shouldn't live here. cc.password = PWD cc.schemes = https and pushing fails. An easy way of duplicating this is forking a project on codeplex (e.g. [1]), cloning that respository, making a trivial commit and then trying to push that commit to your fork. When I try this pushing fails because the authentication details are being ignored in ``.git/hg/origin/clone/.hg/hgrc``. Applying my patch (or your improved version using repo.ui instead of repo._unfilteredrepo.ui) fixes this for me. [1] https://boogie.codeplex.com/SourceControl/latest ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc 2014-04-20 20:36 ` Delcypher @ 2014-04-20 20:48 ` Felipe Contreras 2014-04-20 21:25 ` Delcypher 0 siblings, 1 reply; 10+ messages in thread From: Felipe Contreras @ 2014-04-20 20:48 UTC (permalink / raw) To: Delcypher, Felipe Contreras; +Cc: git Delcypher wrote: > > Same as me. And which version of git-remote-hg are you using? > > I'm using the version that ships with git 1.9.2 > > I've taken a look and it seems I made a mistake, sorry. It seems that > > [ui] > quiet = True > > is being respected when placed in ``.git/hg/origin/clone/.hg/hgrc`` > > with the un patched version of git-remote-hg. > > But it is still the case that authentication details are being ignored > when present in ``.git/hg/origin/clone/.hg/hgrc`` > > i.e. something like the following is ignored. > > [auth] > cc.prefix = hg.codeplex.com > cc.username = USERNAME > # Eurgh fixme this shouldn't live here. > cc.password = PWD > cc.schemes = https I see now, I've taken the patch with repo.ui and applied on my repo: https://github.com/felipec/git/commit/ee17fe1cf80d5196be382ebbbcb1a24c05e61658 If Junio wants to take that he can add my s-o-b. Cheers. -- Felipe Contreras ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc 2014-04-20 20:48 ` Felipe Contreras @ 2014-04-20 21:25 ` Delcypher 0 siblings, 0 replies; 10+ messages in thread From: Delcypher @ 2014-04-20 21:25 UTC (permalink / raw) To: Felipe Contreras; +Cc: git > I see now, I've taken the patch with repo.ui and applied on my repo: > > https://github.com/felipec/git/commit/ee17fe1cf80d5196be382ebbbcb1a24c05e61658 Thanks. It might be helpful to catch the exception raised if https authentication details are missing so that a more user friendly error message can be presented. I considered doing this but I wasn't entirely sure how to correctly do any necessary clean up. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2014-04-20 21:25 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-02-21 15:17 [PATCH] git-remote-hg : Enable use of, $GIT_DIR/hg/origin/clone/.hg/hgrc Daniel Liew 2014-03-24 15:07 ` Delcypher 2014-04-12 20:01 ` Felipe Contreras 2014-04-15 15:37 ` Delcypher 2014-04-20 18:12 ` Felipe Contreras 2014-04-20 19:57 ` Delcypher 2014-04-20 19:54 ` Felipe Contreras 2014-04-20 20:36 ` Delcypher 2014-04-20 20:48 ` Felipe Contreras 2014-04-20 21:25 ` Delcypher
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).