Pierre-Yves David avatar Pierre-Yves David committed 39eb12b

commit --amend: adap to core 63e45aee46d4

commit is now able to create obsolete marker itself. We don't alter core if we
detect it's the case.

Comments (0)

Files changed (2)

 #
 # The precursor is still strip from the repository.
 
-@eh.wrapfunction(cmdutil, 'amend')
-def wrapcmdutilamend(orig, ui, repo, commitfunc, old, *args, **kwargs):
-    oldnode = old.node()
-    new = orig(ui, repo, commitfunc, old, *args, **kwargs)
-    if new != oldnode:
-        lock = repo.lock()
-        try:
-            tr = repo.transaction('post-amend-obst')
+# IN CORE 63e45aee46d4
+
+if getattr(cmdutil, 'obsolete', None) is None:
+    @eh.wrapfunction(cmdutil, 'amend')
+    def wrapcmdutilamend(orig, ui, repo, commitfunc, old, *args, **kwargs):
+        oldnode = old.node()
+        new = orig(ui, repo, commitfunc, old, *args, **kwargs)
+        if new != oldnode:
+            lock = repo.lock()
             try:
-                meta = {
-                    'date':  '%i %i' % util.makedate(),
-                    'user': ui.username(),
-                    }
-                repo.obsstore.create(tr, oldnode, [new], 0, meta)
-                tr.close()
-                clearobscaches(repo)
+                tr = repo.transaction('post-amend-obst')
+                try:
+                    meta = {
+                        'date':  '%i %i' % util.makedate(),
+                        'user': ui.username(),
+                        }
+                    repo.obsstore.create(tr, oldnode, [new], 0, meta)
+                    tr.close()
+                    clearobscaches(repo)
+                finally:
+                    tr.release()
             finally:
-                tr.release()
-        finally:
-            lock.release()
-    return new
+                lock.release()
+        return new
 
 ### rebase
 #

tests/test-obsolete.t

   $ mkcommit f
   created new head
   $ echo 42 >> f
-  $ hg commit --amend --traceback
-  saved backup bundle to $TESTTMP/local/.hg/strip-backup/0b1b6dd009c0-amend-backup.hg
+  $ hg commit --amend --traceback --quiet
   $ hg glog
-  @  changeset:   13:3734a65252e6
+  @  changeset:   1[35]:3734a65252e6 (re)
   |  tag:         tip
   |  parent:      10:2033b4e49474
   |  user:        test
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     add a
   
-  $ hg debugobsolete
+  $ hg debugobsolete | grep -v 33d458d86621f3186c40bfccd77652f4a122743e
   4538525df7e2b9f09423636c61ef63a4cb872a2d 0d3f46688ccc6e756c7e96cf64c391c411309597 0 {'date': '', 'user': 'test'} (glob)
   0d3f46688ccc6e756c7e96cf64c391c411309597 725c380fe99b5e76613493f0903e8d11ddc70d54 0 {'date': '', 'user': 'test'} (glob)
   a7a6f2b5d8a54b81bc7aa2fba2934ad6d700a79e 95de7fc6918dea4c9c8d5382f50649794b474c4a 0 {'date': '', 'user': 'test'} (glob)
   159dfc9fa5d334d7e03a0aecfc7f7ab4c3431fea 9468a5f5d8b2c5d91e17474e95ae4791e9718fdf 0 {'date': '* *', 'user': 'test'} (glob)
   9468a5f5d8b2c5d91e17474e95ae4791e9718fdf 6db5e282cb91df5c43ff1f1287c119ff83230d42 0 {'date': '', 'user': 'test'} (glob)
   0b1b6dd009c037985363e2290a0b579819f659db 3734a65252e69ddcced85901647a4f335d40de1e 0 {'date': '* *', 'user': 'test'} (glob)
+#no produced by 2.3
+33d458d86621f3186c40bfccd77652f4a122743e 3734a65252e69ddcced85901647a4f335d40de1e 0 {'date': '* *', 'user': 'test'} (glob)
 
 Check conflict detection
 
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   $ mkcommit "obsolet_conflicting_d"
   $ hg summary
-  parent: 14:50f11e5e3a63 tip
+  parent: 1[46]:50f11e5e3a63 tip (re)
    add obsolet_conflicting_d
   branch: default
   commit: (clean)
-  update: 9 new changesets, 9 branch heads (merge)
+  update: (9|11) new changesets, (9|10) branch heads \(merge\) (re)
   latecomer: 1 changesets
   $ hg debugobsolete `getid a7a6f2b5d8a5` `getid 50f11e5e3a63`
   $ hg log -r 'conflicting()'
-  changeset:   14:50f11e5e3a63
+  changeset:   1[46]:50f11e5e3a63 (re)
   tag:         tip
   parent:      11:9468a5f5d8b2
   user:        test
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.