Commits

Ryan Schmidt authored cb6b69d9487
hg-forest: update to 20111009

git-svn-id: https://svn.macports.org/repository/macports/trunk/dports@98008 d073be05-634f-4543-b044-5fe20cf6d1d6
No tags

devel/hg-forest/files/forest.py

Modified
255 255 if hasattr(self.repo, "revlogversion"):
256 256 version = self.repo.revlogversion
257 257 else:
258 258 version = self.repo.changelog.version
259 259 caps.append('stream=%d' % version)
260 260 self.respond("capabilities: %s\n" % (' '.join(caps),))
261 261
262 262 sshserver.sshserver.do_hello = _sshserver_do_hello
263 263
264 264
265 +try:
266 + from mercurial import wireproto
267 + # Force the lazy importer to trigger
268 + wireproto.capabilities
269 +except ImportError:
270 + pass
271 +else:
272 + # hg >= 1.7
273 + _old_caps = wireproto.capabilities
274 + def _forest_caps(*args, **kwargs):
275 + caps = _old_caps(*args, **kwargs)
276 + caps += ' forests'
277 + return caps
278 + wireproto.capabilities = _forest_caps
279 +
280 + def do_forests(repo, proto, walkhg):
281 + forests = repo.forests(bool(walkhg))
282 + return "\n".join(forests)
283 + wireproto.commands['forests'] = (do_forests, 'walkhg')
284 +
285 +
286 +
265 287 def _sshserver_do_forests(self):
266 288 """Shim this function into the sshserver so that it responds to
267 289 the forests command. It gives a list of roots relative to the
268 290 self.repo repository, sorted lexigraphically.
269 291 """
270 -
292 + # hg < 1.7
271 293 key, walkhg = self.getarg()
272 294 forests = self.repo.forests(bool(walkhg))
273 295 self.respond("\n".join(forests))
274 296
275 297 sshserver.sshserver.do_forests = _sshserver_do_forests
276 298
277 299
278 300
279 301 def _httprepo_forests(self, walkhg):
280 302 """Shim this function into mercurial.httprepo.httprepository so
573 595
574 596 def working_revs(self):
575 597 """Returns the revision of the working copy."""
576 598 try:
577 599 ctx = self.repo[None]
578 600 except TypeError:
579 601 ctx = self.repo.workingctx()
580 602 parents = ctx.parents()
581 603 return [node.hex(parents[0].node())]
582 604
605 + def rollback(self):
606 + if self._repo:
607 + try:
608 + self._repo.transaction('forest').__del__()
609 + except TypeError, err:
610 + # Wrong number of arguments for hg < 1.6
611 + if '2 given' not in str(err):
612 + raise
613 + self._repo.transaction().__del__()
614 +
583 615 def __repr__(self):
584 616 return ("<forest.Tree object "
585 617 "- repo: %s "
586 618 "- revs: %s "
587 619 "- root: %s "
588 620 "- paths: %s>") % (self.repo, self.revs,
589 621 self.root, self.paths)
590 622
591 623 repo = property(getrepo, setrepo, None, None)
592 624 root = property(getroot, setroot, None, None)
899 931
900 932 Look at the help text for the fetch command for more information.
901 933 """
902 934
903 935 snapfile = opts['snapfile']
904 936 forest = Forest(top=top, snapfile=snapfile,
905 937 walkhg=walkhgenabled(ui, opts['walkhg']))
906 938 source = [source]
907 939 try:
908 940 import hgext.fetch as fetch
941 + # Force the lazy importer to trigger
942 + fetch.cmdtable
909 943 except ImportError:
910 944 raise util.Abort(_("could not import fetch module\n"))
911 945
912 946 def function(tree, srcpath, opts):
913 947 if not srcpath:
914 948 srcpath = forest.top().getpath(source)
915 949 if srcpath:
916 950 rpath = util.pconvert(relpath(forest.top().root, tree.root))
917 951 srcpath = '/'.join((srcpath, rpath))
918 952 else:
919 953 ui.warn(_("skipped: %s\n") %
920 954 _("repository %s not found") % source[0])
921 955 return
922 956 try:
923 957 fetch.fetch(ui, tree.getrepo(ui), srcpath, **opts)
924 958 except Exception, err:
925 959 ui.warn(_("skipped: %s\n") % err)
926 - try:
927 - tree.repo.transaction().__del__()
928 - except AttributeError:
929 - pass
960 + tree.rollback()
930 961
931 962 @Forest.Tree.skip
932 963 def check_mq(tree):
933 964 tree.die_on_mq(top.root)
934 965
935 966 forest.apply(ui, function, source, opts,
936 967 prehooks=[lambda tree: check_mq(tree)])
937 968
938 969
939 970 def incoming(ui, top, source="default", **opts):
1093 1124 dest=destpath, rpath=rpath,
1094 1125 opts=opts)
1095 1126 except util.Abort, err:
1096 1127 ui.warn(_("skipped: %s\n") % err)
1097 1128 ui.quiet = quiet
1098 1129 return
1099 1130 try:
1100 1131 commands.pull(ui, tree.getrepo(ui), srcpath, **opts)
1101 1132 except Exception, err:
1102 1133 ui.warn(_("skipped: %s\n") % err)
1103 - if tree._repo:
1104 - tree.repo.transaction().__del__()
1134 + tree.rollback()
1105 1135
1106 1136 @Forest.Tree.skip
1107 1137 def check_mq(tree):
1108 1138 tree.die_on_mq(top.root)
1109 1139
1110 1140 forest.apply(ui, function, source, opts,
1111 1141 prehooks=[lambda tree: check_mq(tree)])
1112 1142
1113 1143 def push(ui, top, dest=None, pathalias=None, **opts):
1114 1144 """push changes to the specified forest.
1134 1164 else:
1135 1165 dest = ["default-push", "default"]
1136 1166 forest = Forest(top=top, snapfile=snapfile,
1137 1167 walkhg=walkhgenabled(ui, opts['walkhg']))
1138 1168
1139 1169 def function(tree, destpath, opts):
1140 1170 try:
1141 1171 commands.push(ui, tree.getrepo(ui), destpath, **opts)
1142 1172 except Exception, err:
1143 1173 ui.warn(_("skipped: %s\n") % err)
1144 - try:
1145 - tree.repo.transaction().__del__()
1146 - except AttributeError:
1147 - pass
1174 + tree.rollback()
1148 1175
1149 1176 @Forest.Tree.skip
1150 1177 def check_mq(tree):
1151 1178 tree.die_on_mq(top.root)
1152 1179
1153 1180 forest.apply(ui, function, dest, opts,
1154 1181 prehooks=[lambda tree: check_mq(tree)])
1155 1182
1156 1183
1157 1184 def seed(ui, snapshot=None, source='default', **opts):
1309 1336 raise util.Abort(_("use only one form to specify the revision"))
1310 1337 opts['rev'] = revision
1311 1338 forest = Forest(top=top, snapfile=None,
1312 1339 walkhg=walkhgenabled(ui, opts['walkhg']))
1313 1340
1314 1341 def function(tree, ignore, opts):
1315 1342 try:
1316 1343 commands.tag(ui, tree.getrepo(ui), name, rev_=None, **opts)
1317 1344 except Exception, err:
1318 1345 ui.warn(_("skipped: %s\n") % err)
1319 - tree.repo.transaction().__del__()
1346 + tree.rollback()
1320 1347
1321 1348 @Forest.Tree.skip
1322 1349 def check_mq(tree):
1323 1350 tree.die_on_mq(top.root)
1324 1351
1325 1352 forest.apply(ui, function, None, opts,
1326 1353 prehooks=[lambda tree: check_mq(tree)])
1327 1354
1328 1355
1329 1356 def trees(ui, top, **opts):
1381 1408 rev = rev[-1]
1382 1409 try:
1383 1410 if rev is not None:
1384 1411 commands.update(ui, tree.getrepo(ui),
1385 1412 rev=rev, clean=opts['clean'], date=opts['date'])
1386 1413 else:
1387 1414 commands.update(ui, tree.getrepo(ui),
1388 1415 clean=opts['clean'], date=opts['date'])
1389 1416 except Exception, err:
1390 1417 ui.warn(_("skipped: %s\n") % err)
1391 - tree.repo.transaction().__del__()
1418 + tree.rollback()
1392 1419
1393 1420 @Forest.Tree.skip
1394 1421 def check_mq(tree):
1395 1422 tree.die_on_mq(top.root)
1396 1423
1397 1424 forest.apply(ui, function, None, opts,
1398 1425 prehooks=[lambda tree: check_mq(tree)])
1399 1426
1400 1427
1401 1428 cmdtable = {}
1468 1495 [snapfileopts,
1469 1496 ('', 'tip', False,
1470 1497 _("use tip instead of revisions stored in the snapshot file")),
1471 1498 walkhgopts]
1472 1499 + cmd_options(ui, 'update'),
1473 1500 _('hg fupdate [OPTION]...'))
1474 1501 }
1475 1502
1476 1503 try:
1477 1504 import hgext.fetch
1505 + # Force the lazy importer to trigger
1506 + hgext.fetch.cmdtable
1478 1507 except ImportError:
1479 1508 return
1480 1509 try:
1481 1510 cmdtable.update({"ffetch": (fetch,
1482 1511 [walkhgopts, snapfileopts]
1483 1512 + cmd_options(ui, 'fetch',
1484 1513 remove=('bundle',),
1485 1514 table=hgext.fetch.cmdtable),
1486 1515 _('hg ffetch [OPTION]... [SOURCE]'))})
1487 1516 except UnknownCommand:

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut