##// END OF EJS Templates
Infer a --repository argument from command arguments when reasonable....
Jesse Glick -
r6150:aafdea37 default
parent child Browse files
Show More
@@ -150,8 +150,7 b' def _runcatch(ui, args):'
150 150
151 151 return -1
152 152
153 def _findrepo():
154 p = os.getcwd()
153 def _findrepo(p):
155 154 while not os.path.isdir(os.path.join(p, ".hg")):
156 155 oldp, p = p, os.path.dirname(p)
157 156 if p == oldp:
@@ -254,7 +253,7 b' def _dispatch(ui, args):'
254 253 os.chdir(cwd[-1])
255 254
256 255 # read the local repository .hgrc into a local ui object
257 path = _findrepo() or ""
256 path = _findrepo(os.getcwd()) or ""
258 257 if not path:
259 258 lui = ui
260 259 if path:
@@ -345,6 +344,11 b' def _dispatch(ui, args):'
345 344 ui.setconfig("bundle", "mainreporoot", repo.root)
346 345 except hg.RepoError:
347 346 if cmd not in commands.optionalrepo.split():
347 if args and not path: # try to infer -R from command args
348 repos = map(_findrepo, args)
349 guess = repos[0]
350 if guess and repos.count(guess) == len(repos):
351 return _dispatch(ui, ['--repository', guess] + fullargs)
348 352 if not path:
349 353 raise hg.RepoError(_("There is no Mercurial repository here"
350 354 " (.hg not found)"))
@@ -25,6 +25,13 b' echo %% -R/--repository'
25 25 hg -R a tip
26 26 hg --repository b tip
27 27
28 echo %% implicit -R
29 hg ann a/a
30 hg ann a/a a/a
31 hg ann a/a b/b
32 hg -R b ann a/a
33 hg log
34
28 35 echo %% abbrev of long option
29 36 hg --repo c tip
30 37
@@ -24,6 +24,12 b' user: test'
24 24 date: Thu Jan 01 00:00:01 1970 +0000
25 25 summary: b
26 26
27 %% implicit -R
28 0: a
29 0: a
30 abort: There is no Mercurial repository here (.hg not found)!
31 abort: a/a not under root
32 abort: There is no Mercurial repository here (.hg not found)!
27 33 %% abbrev of long option
28 34 changeset: 1:b6c483daf290
29 35 tag: tip
General Comments 0
You need to be logged in to leave comments. Login now