Show More
@@ -14,6 +14,23 b' propertycache = util.propertycache' | |||
|
14 | 14 | |
|
15 | 15 | nullstate = ('', '', 'empty') |
|
16 | 16 | |
|
17 | class SubrepoAbort(error.Abort): | |
|
18 | """Exception class used to avoid handling a subrepo error more than once""" | |
|
19 | ||
|
20 | def annotatesubrepoerror(func): | |
|
21 | def decoratedmethod(self, *args, **kargs): | |
|
22 | try: | |
|
23 | res = func(self, *args, **kargs) | |
|
24 | except SubrepoAbort, ex: | |
|
25 | # This exception has already been handled | |
|
26 | raise ex | |
|
27 | except error.Abort, ex: | |
|
28 | errormsg = _('%s (in subrepo %s)') % (str(ex), subrelpath(self)) | |
|
29 | # avoid handling this exception by raising a SubrepoAbort exception | |
|
30 | raise SubrepoAbort(errormsg, hint=ex.hint) | |
|
31 | return res | |
|
32 | return decoratedmethod | |
|
33 | ||
|
17 | 34 | def state(ctx, ui): |
|
18 | 35 | """return a state dict, mapping subrepo paths configured in .hgsub |
|
19 | 36 | to tuple: (source from .hgsub, revision from .hgsubstate, kind |
@@ -244,8 +261,7 b' def _abssource(repo, push=False, abort=T' | |||
|
244 | 261 | if repo.ui.config('paths', 'default'): |
|
245 | 262 | return repo.ui.config('paths', 'default') |
|
246 | 263 | if abort: |
|
247 |
raise util.Abort(_("default path for subrepository |
|
|
248 | reporelpath(repo)) | |
|
264 | raise util.Abort(_("default path for subrepository not found")) | |
|
249 | 265 | |
|
250 | 266 | def itersubrepos(ctx1, ctx2): |
|
251 | 267 | """find subrepos in ctx1 or ctx2""" |
@@ -402,6 +418,7 b' class hgsubrepo(abstractsubrepo):' | |||
|
402 | 418 | self._repo.ui.setconfig(s, k, v) |
|
403 | 419 | self._initrepo(r, state[0], create) |
|
404 | 420 | |
|
421 | @annotatesubrepoerror | |
|
405 | 422 | def _initrepo(self, parentrepo, source, create): |
|
406 | 423 | self._repo._subparent = parentrepo |
|
407 | 424 | self._repo._subsource = source |
@@ -422,10 +439,12 b' class hgsubrepo(abstractsubrepo):' | |||
|
422 | 439 | addpathconfig('default-push', defpushpath) |
|
423 | 440 | fp.close() |
|
424 | 441 | |
|
442 | @annotatesubrepoerror | |
|
425 | 443 | def add(self, ui, match, dryrun, listsubrepos, prefix, explicitonly): |
|
426 | 444 | return cmdutil.add(ui, self._repo, match, dryrun, listsubrepos, |
|
427 | 445 | os.path.join(prefix, self._path), explicitonly) |
|
428 | 446 | |
|
447 | @annotatesubrepoerror | |
|
429 | 448 | def status(self, rev2, **opts): |
|
430 | 449 | try: |
|
431 | 450 | rev1 = self._state[1] |
@@ -437,6 +456,7 b' class hgsubrepo(abstractsubrepo):' | |||
|
437 | 456 | % (inst, subrelpath(self))) |
|
438 | 457 | return [], [], [], [], [], [], [] |
|
439 | 458 | |
|
459 | @annotatesubrepoerror | |
|
440 | 460 | def diff(self, ui, diffopts, node2, match, prefix, **opts): |
|
441 | 461 | try: |
|
442 | 462 | node1 = node.bin(self._state[1]) |
@@ -452,6 +472,7 b' class hgsubrepo(abstractsubrepo):' | |||
|
452 | 472 | self._repo.ui.warn(_('warning: error "%s" in subrepository "%s"\n') |
|
453 | 473 | % (inst, subrelpath(self))) |
|
454 | 474 | |
|
475 | @annotatesubrepoerror | |
|
455 | 476 | def archive(self, ui, archiver, prefix, match=None): |
|
456 | 477 | self._get(self._state + ('hg',)) |
|
457 | 478 | abstractsubrepo.archive(self, ui, archiver, prefix, match) |
@@ -463,6 +484,7 b' class hgsubrepo(abstractsubrepo):' | |||
|
463 | 484 | submatch = matchmod.narrowmatcher(subpath, match) |
|
464 | 485 | s.archive(ui, archiver, os.path.join(prefix, self._path), submatch) |
|
465 | 486 | |
|
487 | @annotatesubrepoerror | |
|
466 | 488 | def dirty(self, ignoreupdate=False): |
|
467 | 489 | r = self._state[1] |
|
468 | 490 | if r == '' and not ignoreupdate: # no state recorded |
@@ -479,6 +501,7 b' class hgsubrepo(abstractsubrepo):' | |||
|
479 | 501 | def checknested(self, path): |
|
480 | 502 | return self._repo._checknested(self._repo.wjoin(path)) |
|
481 | 503 | |
|
504 | @annotatesubrepoerror | |
|
482 | 505 | def commit(self, text, user, date): |
|
483 | 506 | # don't bother committing in the subrepo if it's only been |
|
484 | 507 | # updated |
@@ -490,6 +513,7 b' class hgsubrepo(abstractsubrepo):' | |||
|
490 | 513 | return self._repo['.'].hex() # different version checked out |
|
491 | 514 | return node.hex(n) |
|
492 | 515 | |
|
516 | @annotatesubrepoerror | |
|
493 | 517 | def remove(self): |
|
494 | 518 | # we can't fully delete the repository as it may contain |
|
495 | 519 | # local-only history |
@@ -519,12 +543,14 b' class hgsubrepo(abstractsubrepo):' | |||
|
519 | 543 | bookmarks.updatefromremote(self._repo.ui, self._repo, other, |
|
520 | 544 | srcurl) |
|
521 | 545 | |
|
546 | @annotatesubrepoerror | |
|
522 | 547 | def get(self, state, overwrite=False): |
|
523 | 548 | self._get(state) |
|
524 | 549 | source, revision, kind = state |
|
525 | 550 | self._repo.ui.debug("getting subrepo %s\n" % self._path) |
|
526 | 551 | hg.updaterepo(self._repo, revision, overwrite) |
|
527 | 552 | |
|
553 | @annotatesubrepoerror | |
|
528 | 554 | def merge(self, state): |
|
529 | 555 | self._get(state) |
|
530 | 556 | cur = self._repo['.'] |
@@ -551,6 +577,7 b' class hgsubrepo(abstractsubrepo):' | |||
|
551 | 577 | else: |
|
552 | 578 | mergefunc() |
|
553 | 579 | |
|
580 | @annotatesubrepoerror | |
|
554 | 581 | def push(self, opts): |
|
555 | 582 | force = opts.get('force') |
|
556 | 583 | newbranch = opts.get('new_branch') |
@@ -569,12 +596,15 b' class hgsubrepo(abstractsubrepo):' | |||
|
569 | 596 | other = hg.peer(self._repo, {'ssh': ssh}, dsturl) |
|
570 | 597 | return self._repo.push(other, force, newbranch=newbranch) |
|
571 | 598 | |
|
599 | @annotatesubrepoerror | |
|
572 | 600 | def outgoing(self, ui, dest, opts): |
|
573 | 601 | return hg.outgoing(ui, self._repo, _abssource(self._repo, True), opts) |
|
574 | 602 | |
|
603 | @annotatesubrepoerror | |
|
575 | 604 | def incoming(self, ui, source, opts): |
|
576 | 605 | return hg.incoming(ui, self._repo, _abssource(self._repo, False), opts) |
|
577 | 606 | |
|
607 | @annotatesubrepoerror | |
|
578 | 608 | def files(self): |
|
579 | 609 | rev = self._state[1] |
|
580 | 610 | ctx = self._repo[rev] |
@@ -593,10 +623,12 b' class hgsubrepo(abstractsubrepo):' | |||
|
593 | 623 | ctx = self._repo[None] |
|
594 | 624 | return ctx.walk(match) |
|
595 | 625 | |
|
626 | @annotatesubrepoerror | |
|
596 | 627 | def forget(self, ui, match, prefix): |
|
597 | 628 | return cmdutil.forget(ui, self._repo, match, |
|
598 | 629 | os.path.join(prefix, self._path), True) |
|
599 | 630 | |
|
631 | @annotatesubrepoerror | |
|
600 | 632 | def revert(self, ui, substate, *pats, **opts): |
|
601 | 633 | # reverting a subrepo is a 2 step process: |
|
602 | 634 | # 1. if the no_backup is not set, revert all modified |
@@ -751,6 +783,7 b' class svnsubrepo(abstractsubrepo):' | |||
|
751 | 783 | pass |
|
752 | 784 | return rev |
|
753 | 785 | |
|
786 | @annotatesubrepoerror | |
|
754 | 787 | def commit(self, text, user, date): |
|
755 | 788 | # user and date are out of our hands since svn is centralized |
|
756 | 789 | changed, extchanged, missing = self._wcchanged() |
@@ -778,6 +811,7 b' class svnsubrepo(abstractsubrepo):' | |||
|
778 | 811 | self._ui.status(self._svncommand(['update', '-r', newrev])[0]) |
|
779 | 812 | return newrev |
|
780 | 813 | |
|
814 | @annotatesubrepoerror | |
|
781 | 815 | def remove(self): |
|
782 | 816 | if self.dirty(): |
|
783 | 817 | self._ui.warn(_('not removing repo %s because ' |
@@ -802,6 +836,7 b' class svnsubrepo(abstractsubrepo):' | |||
|
802 | 836 | except OSError: |
|
803 | 837 | pass |
|
804 | 838 | |
|
839 | @annotatesubrepoerror | |
|
805 | 840 | def get(self, state, overwrite=False): |
|
806 | 841 | if overwrite: |
|
807 | 842 | self._svncommand(['revert', '--recursive']) |
@@ -822,6 +857,7 b' class svnsubrepo(abstractsubrepo):' | |||
|
822 | 857 | raise util.Abort((status or err).splitlines()[-1]) |
|
823 | 858 | self._ui.status(status) |
|
824 | 859 | |
|
860 | @annotatesubrepoerror | |
|
825 | 861 | def merge(self, state): |
|
826 | 862 | old = self._state[1] |
|
827 | 863 | new = state[1] |
@@ -835,6 +871,7 b' class svnsubrepo(abstractsubrepo):' | |||
|
835 | 871 | # push is a no-op for SVN |
|
836 | 872 | return True |
|
837 | 873 | |
|
874 | @annotatesubrepoerror | |
|
838 | 875 | def files(self): |
|
839 | 876 | output = self._svncommand(['list', '--recursive', '--xml'])[0] |
|
840 | 877 | doc = xml.dom.minidom.parseString(output) |
@@ -1021,6 +1058,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
1021 | 1058 | raise util.Abort(_("revision %s does not exist in subrepo %s\n") % |
|
1022 | 1059 | (revision, self._relpath)) |
|
1023 | 1060 | |
|
1061 | @annotatesubrepoerror | |
|
1024 | 1062 | def dirty(self, ignoreupdate=False): |
|
1025 | 1063 | if self._gitmissing(): |
|
1026 | 1064 | return self._state[1] != '' |
@@ -1037,6 +1075,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
1037 | 1075 | def basestate(self): |
|
1038 | 1076 | return self._gitstate() |
|
1039 | 1077 | |
|
1078 | @annotatesubrepoerror | |
|
1040 | 1079 | def get(self, state, overwrite=False): |
|
1041 | 1080 | source, revision, kind = state |
|
1042 | 1081 | if not revision: |
@@ -1120,6 +1159,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
1120 | 1159 | # a real merge would be required, just checkout the revision |
|
1121 | 1160 | rawcheckout() |
|
1122 | 1161 | |
|
1162 | @annotatesubrepoerror | |
|
1123 | 1163 | def commit(self, text, user, date): |
|
1124 | 1164 | if self._gitmissing(): |
|
1125 | 1165 | raise util.Abort(_("subrepo %s is missing") % self._relpath) |
@@ -1137,6 +1177,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
1137 | 1177 | # circumstances |
|
1138 | 1178 | return self._gitstate() |
|
1139 | 1179 | |
|
1180 | @annotatesubrepoerror | |
|
1140 | 1181 | def merge(self, state): |
|
1141 | 1182 | source, revision, kind = state |
|
1142 | 1183 | self._fetch(source, revision) |
@@ -1159,6 +1200,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
1159 | 1200 | else: |
|
1160 | 1201 | mergefunc() |
|
1161 | 1202 | |
|
1203 | @annotatesubrepoerror | |
|
1162 | 1204 | def push(self, opts): |
|
1163 | 1205 | force = opts.get('force') |
|
1164 | 1206 | |
@@ -1198,6 +1240,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
1198 | 1240 | (self._relpath, self._state[1])) |
|
1199 | 1241 | return False |
|
1200 | 1242 | |
|
1243 | @annotatesubrepoerror | |
|
1201 | 1244 | def remove(self): |
|
1202 | 1245 | if self._gitmissing(): |
|
1203 | 1246 | return |
@@ -1247,6 +1290,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
1247 | 1290 | ui.progress(_('archiving (%s)') % relpath, None) |
|
1248 | 1291 | |
|
1249 | 1292 | |
|
1293 | @annotatesubrepoerror | |
|
1250 | 1294 | def status(self, rev2, **opts): |
|
1251 | 1295 | rev1 = self._state[1] |
|
1252 | 1296 | if self._gitmissing() or not rev1: |
@@ -331,10 +331,10 b" Don't crash if the subrepo is missing" | |||
|
331 | 331 | $ hg sum | grep commit |
|
332 | 332 | commit: 1 subrepos |
|
333 | 333 | $ hg push -q |
|
334 | abort: subrepo s is missing | |
|
334 | abort: subrepo s is missing (in subrepo s) | |
|
335 | 335 | [255] |
|
336 | 336 | $ hg commit --subrepos -qm missing |
|
337 | abort: subrepo s is missing | |
|
337 | abort: subrepo s is missing (in subrepo s) | |
|
338 | 338 | [255] |
|
339 | 339 | $ hg update -C |
|
340 | 340 | cloning subrepo s from $TESTTMP/gitroot |
@@ -386,7 +386,7 b' created by archive:' | |||
|
386 | 386 | $ echo f > foo/f |
|
387 | 387 | $ hg archive --subrepos -r tip archive |
|
388 | 388 | cloning subrepo foo from $TESTTMP/empty/foo |
|
389 | abort: destination '$TESTTMP/almost-empty/foo' is not empty (glob) | |
|
389 | abort: destination '$TESTTMP/almost-empty/foo' is not empty (in subrepo foo) (glob) | |
|
390 | 390 | [255] |
|
391 | 391 | |
|
392 | 392 | Clone and test outgoing: |
@@ -119,7 +119,7 b' missing svn file, commit should fail' | |||
|
119 | 119 | $ rm s/alpha |
|
120 | 120 | $ hg commit --subrepos -m 'abort on missing file' |
|
121 | 121 | committing subrepository s |
|
122 | abort: cannot commit missing svn entries | |
|
122 | abort: cannot commit missing svn entries (in subrepo s) | |
|
123 | 123 | [255] |
|
124 | 124 | $ svn revert s/alpha > /dev/null |
|
125 | 125 | |
@@ -180,7 +180,7 b' this commit fails because of externals c' | |||
|
180 | 180 | $ echo zzz > s/externals/other |
|
181 | 181 | $ hg ci --subrepos -m 'amend externals from hg' |
|
182 | 182 | committing subrepository s |
|
183 | abort: cannot commit svn externals | |
|
183 | abort: cannot commit svn externals (in subrepo s) | |
|
184 | 184 | [255] |
|
185 | 185 | $ hg diff --subrepos -r 1:2 | grep -v diff |
|
186 | 186 | --- a/.hgsubstate Thu Jan 01 00:00:00 1970 +0000 |
@@ -202,7 +202,7 b' this commit fails because of externals m' | |||
|
202 | 202 | property 'svn:mime-type' set on 's/externals/other' (glob) |
|
203 | 203 | $ hg ci --subrepos -m 'amend externals from hg' |
|
204 | 204 | committing subrepository s |
|
205 | abort: cannot commit svn externals | |
|
205 | abort: cannot commit svn externals (in subrepo s) | |
|
206 | 206 | [255] |
|
207 | 207 | $ svn revert -q s/externals/other |
|
208 | 208 |
@@ -320,7 +320,7 b' push -f' | |||
|
320 | 320 | no changes found |
|
321 | 321 | pushing subrepo s to $TESTTMP/t/s (glob) |
|
322 | 322 | searching for changes |
|
323 | abort: push creates new remote head 12a213df6fa9! | |
|
323 | abort: push creates new remote head 12a213df6fa9! (in subrepo s) | |
|
324 | 324 | (did you forget to merge? use push -f to force) |
|
325 | 325 | [255] |
|
326 | 326 | $ hg push -f |
@@ -587,7 +587,7 b' Issue1977: multirepo push should fail if' | |||
|
587 | 587 | created new head |
|
588 | 588 | $ hg -R repo2 ci -m3 |
|
589 | 589 | $ hg -q -R repo2 push |
|
590 | abort: push creates new remote head cc505f09a8b2! | |
|
590 | abort: push creates new remote head cc505f09a8b2! (in subrepo s) | |
|
591 | 591 | (did you forget to merge? use push -f to force) |
|
592 | 592 | [255] |
|
593 | 593 | $ hg -R repo update |
@@ -599,7 +599,7 b' test if untracked file is not overwritte' | |||
|
599 | 599 | $ hg -R repo2 push -f -q |
|
600 | 600 | $ hg -R repo update |
|
601 | 601 | b: untracked file differs |
|
602 | abort: untracked files in working directory differ from files in requested revision | |
|
602 | abort: untracked files in working directory differ from files in requested revision (in subrepo s) | |
|
603 | 603 | [255] |
|
604 | 604 | |
|
605 | 605 | $ cat repo/s/b |
@@ -645,7 +645,7 b' Create repo without default path, pull t' | |||
|
645 | 645 | added 2 changesets with 3 changes to 2 files |
|
646 | 646 | (run 'hg update' to get a working copy) |
|
647 | 647 | $ hg -R issue1852b update |
|
648 |
abort: default path for subrepository |
|
|
648 | abort: default path for subrepository not found (in subrepo sub/repo) (glob) | |
|
649 | 649 | [255] |
|
650 | 650 | |
|
651 | 651 | Pull -u now doesn't help |
General Comments 0
You need to be logged in to leave comments.
Login now