Commits

Pierre-Yves David committed 63f267b

obsolete: basic commit --amend support

commit --amend still strip. but lay obsolete marker down anyway

Comments (0)

Files changed (2)

hgext/obsolete.py

     repo._turn_extinct_secret()
     return orig(repo)
 
+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:
+            newmarker = {
+                'subjects':  [new],
+                'object': oldnode,
+                'date':  util.makedate(),
+                'user': ui.username(),
+                'reason': 'commit --amend',
+                }
+            repo.obsoletestore.new(newmarker)
+            repo._clearobsoletecache()
+            repo._turn_extinct_secret()
+        finally:
+            lock.release()
+    return new
+
 def uisetup(ui):
     extensions.wrapcommand(commands.table, "update", wrapmayobsoletewc)
     extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc)
+    if util.safehasattr(cmdutil, 'amend'):
+        extensions.wrapfunction(cmdutil, 'amend', wrapcmdutilamend)
     extensions.wrapfunction(discovery, 'findcommonoutgoing', wrapfindcommonoutgoing)
     extensions.wrapfunction(discovery, 'checkheads', wrapcheckheads)
     extensions.wrapfunction(phases, 'visibleheads', noextinctsvisibleheads)

tests/test-obsolete.t

   abort: Trying to push latecomer changeset: 6db5e282cb91!
   (use 'hg stabilize' to get a stable history (or --force to proceed))
   [255]
+
+Check hg commit --amend compat
+
+  $ hg up 'desc(obsol_c)'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ 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 glog
+  @  changeset:   13:3734a65252e6
+  |  tag:         tip
+  |  parent:      10:2033b4e49474
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     add f
+  |
+  | o  changeset:   12:6db5e282cb91
+  |/   parent:      10:2033b4e49474
+  |    user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     add obsol_d'''
+  |
+  | o  changeset:   11:9468a5f5d8b2
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     add obsol_d''
+  |
+  o  changeset:   10:2033b4e49474
+  |  parent:      4:725c380fe99b
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     add obsol_c
+  |
+  o  changeset:   4:725c380fe99b
+  |  parent:      1:7c3bad9141dc
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     add obsol_c'
+  |
+  o  changeset:   1:7c3bad9141dc
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     add b
+  |
+  o  changeset:   0:1f0dee641bb7
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     add a
+  
+  $ hg debugsuccessors
+  0b1b6dd009c0 3734a65252e6
+  0d3f46688ccc 2033b4e49474
+  0d3f46688ccc 725c380fe99b
+  159dfc9fa5d3 9468a5f5d8b2
+  1f0dee641bb7 83b5778897ad
+  4538525df7e2 0d3f46688ccc
+  83b5778897ad 000000000000
+  909a0fb57e5d 159dfc9fa5d3
+  9468a5f5d8b2 6db5e282cb91
+  95de7fc6918d 909a0fb57e5d
+  a7a6f2b5d8a5 95de7fc6918d
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.