##// END OF EJS Templates
mq: create patch file after commit to import diff of ".hgsubstate" at qrefresh...
FUJIWARA Katsunori -
r17152:f287d4a6 default
parent child Browse files
Show More
@@ -946,6 +946,18 b' class queue(object):'
946 inclsubs.append(s)
946 inclsubs.append(s)
947 return inclsubs
947 return inclsubs
948
948
949 def putsubstate2changes(self, substatestate, changes):
950 for files in changes[:3]:
951 if '.hgsubstate' in files:
952 return # already listed up
953 # not yet listed up
954 if substatestate in 'a?':
955 changes[1].append('.hgsubstate')
956 elif substatestate in 'r':
957 changes[2].append('.hgsubstate')
958 else: # modified
959 changes[0].append('.hgsubstate')
960
949 def localchangesfound(self, refresh=True):
961 def localchangesfound(self, refresh=True):
950 if refresh:
962 if refresh:
951 raise util.Abort(_("local changes found, refresh first"))
963 raise util.Abort(_("local changes found, refresh first"))
@@ -1064,17 +1076,7 b' class queue(object):'
1064 if commitfiles:
1076 if commitfiles:
1065 parent = self.qparents(repo, n)
1077 parent = self.qparents(repo, n)
1066 if inclsubs:
1078 if inclsubs:
1067 for files in changes[:3]:
1079 self.putsubstate2changes(substatestate, changes)
1068 if '.hgsubstate' in files:
1069 break # already listed up
1070 else:
1071 # not yet listed up
1072 if substatestate in 'a?':
1073 changes[1].append('.hgsubstate')
1074 elif substatestate in 'r':
1075 changes[2].append('.hgsubstate')
1076 else: # modified
1077 changes[0].append('.hgsubstate')
1078 chunks = patchmod.diff(repo, node1=parent, node2=n,
1080 chunks = patchmod.diff(repo, node1=parent, node2=n,
1079 changes=changes, opts=diffopts)
1081 changes=changes, opts=diffopts)
1080 for chunk in chunks:
1082 for chunk in chunks:
@@ -1487,6 +1489,9 b' class queue(object):'
1487 hint=_('see "hg help phases" for details'))
1489 hint=_('see "hg help phases" for details'))
1488
1490
1489 inclsubs = self.checksubstate(repo)
1491 inclsubs = self.checksubstate(repo)
1492 if inclsubs:
1493 inclsubs.append('.hgsubstate')
1494 substatestate = repo.dirstate['.hgsubstate']
1490
1495
1491 cparents = repo.changelog.parents(top)
1496 cparents = repo.changelog.parents(top)
1492 patchparent = self.qparents(repo, top)
1497 patchparent = self.qparents(repo, top)
@@ -1567,10 +1572,6 b' class queue(object):'
1567 a = list(aa)
1572 a = list(aa)
1568 c = [filter(matchfn, l) for l in (m, a, r)]
1573 c = [filter(matchfn, l) for l in (m, a, r)]
1569 match = scmutil.matchfiles(repo, set(c[0] + c[1] + c[2] + inclsubs))
1574 match = scmutil.matchfiles(repo, set(c[0] + c[1] + c[2] + inclsubs))
1570 chunks = patchmod.diff(repo, patchparent, match=match,
1571 changes=c, opts=diffopts)
1572 for chunk in chunks:
1573 patchf.write(chunk)
1574
1575
1575 try:
1576 try:
1576 if diffopts.git or diffopts.upgrade:
1577 if diffopts.git or diffopts.upgrade:
@@ -1649,6 +1650,12 b' class queue(object):'
1649 n = newcommit(repo, oldphase, message, user, ph.date,
1650 n = newcommit(repo, oldphase, message, user, ph.date,
1650 match=match, force=True)
1651 match=match, force=True)
1651 # only write patch after a successful commit
1652 # only write patch after a successful commit
1653 if inclsubs:
1654 self.putsubstate2changes(substatestate, c)
1655 chunks = patchmod.diff(repo, patchparent,
1656 changes=c, opts=diffopts)
1657 for chunk in chunks:
1658 patchf.write(chunk)
1652 patchf.close()
1659 patchf.close()
1653 self.applied.append(statusentry(n, patchfn))
1660 self.applied.append(statusentry(n, patchfn))
1654 except: # re-raises
1661 except: # re-raises
@@ -412,6 +412,35 b" both into 'revision' and 'patch file und"
412 applying import-at-qnew
412 applying import-at-qnew
413 now at: import-at-qnew
413 now at: import-at-qnew
414
414
415 $ hg qnew import-at-qrefresh
416 $ echo sb > sub/sb
417 $ hg -R sub commit -u test -d '0 0' -Am '#1 in sub'
418 adding sb
419 $ hg qrefresh -u test -d '0 0'
420 $ hg -R sub parents --template '{node} sub\n'
421 88ac1bef5ed43b689d1d200b59886b675dec474b sub
422 $ cat .hgsubstate
423 88ac1bef5ed43b689d1d200b59886b675dec474b sub
424 $ hg diff -c tip
425 diff -r 44f846335325 -r b3e8c5fa3aaa .hgsubstate
426 --- a/.hgsubstate
427 +++ b/.hgsubstate
428 @@ -1,1 +1,1 @@
429 -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
430 +88ac1bef5ed43b689d1d200b59886b675dec474b sub
431 $ cat .hg/patches/import-at-qrefresh
432 # HG changeset patch
433 # Date 0 0
434 # User test
435 # Parent 44f846335325209be6be35dc2c9a4be107278c09
436
437 diff -r 44f846335325 .hgsubstate
438 --- a/.hgsubstate
439 +++ b/.hgsubstate
440 @@ -1,1 +1,1 @@
441 -b6f6e9c41f3dfd374a6d2ed4535c87951cf979cf sub
442 +88ac1bef5ed43b689d1d200b59886b675dec474b sub
443
415 $ cd ..
444 $ cd ..
416
445
417 $ cd ..
446 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now