mercurial使用

Since we have presented a way to review the history of committed changes using Git, Team Foundation Server and Subversion, let’s check how the same can be achieved when working with the Mercurial source control system.

由于我们提供了一种使用Git , Team Foundation Server和Subversion来查看已提交更改的历史的方法,因此让我们检查一下在使用Mercurial源代码控制系统时如何实现相同的更改。

We’ll be using Tortoise Hg, free Mercurial client that comes with Windows shell integration. For the purpose of this article we’ll use a sample database called StoresDB whose objects are scripted in separate files and saved in a local folder called MercLocal. The same folder is initialized to be a local Mercurial repository. I won’t include details about initializing the repository and committing changes. The goal of the article is to cover the following: revision history of all committed changes, comparing two versions of the same object committed in two different changesets and getting specific version of an object from the commit history.

我们将使用Windows Shell集成随附的免费Mercurial客户端Tortoise Hg 。 就本文而言,我们将使用一个名为StoresDB的示例数据库,该数据库的对象被编写在单独的文件中,并保存在名为MercLocal的本地文件夹中。 相同的文件夹被初始化为本地Mercurial存储库。 我不会提供有关初始化存储库和提交更改的详细信息。 本文的目的是涵盖以下内容:所有已提交更改的修订历史记录,比较在两个不同变更集中提交的同一对象的两个版本,并从提交历史记录中获取对象的特定版本。

As a starting point, let’s assume that the following tasks were performed against previously scripted database object files:

首先,假设对先前编写脚本的数据库对象文件执行了以下任务:

  • Initial commit of all database objects

    初始提交所有数据库对象

  • Committing a new table called Balances using the following SQL script:

    使用以下SQL脚本提交一个名为Balances的新表:

    
    CREATE TABLE [dbo].[Balances]([BalanceID] [varchar](15) PRIMARY KEY NOT NULL,[Description] [varchar](255) NULL,[DocID] INT IDENTITY(1,1) NOT NULL)GO
  • In the next changeset the following changes are committed:

    在下一个变更集中,将进行以下更改:

    • New column called BalanceType is added to the Balances table using the following SQL script:

      使用以下SQL脚本,将称为BalanceType的新列添加到Balances表中:

      
      ALTER TABLE dbo.Balances ADD BalanceType NVARCHAR(50)
    • New stored procedure called BalancesList is created using the following script:

      使用以下脚本创建名为BalancesList的新存储过程:

      
      CREATE PROCEDURE dbo.BalancesList
      AS
      BEGIN
      SELECT BalanceID, Description, DocID FROM dbo.Balances
      END
      GO
    • New column added to the ProductCategory table:

      新列添加到ProductCategory表:

      
      ALTER TABLE Production.ProductCategoryADD CategoryDescription NVARCHAR (255)
  • The next changeset holds just a single edit. The previously created BalanceType column in the Balances table is renamed using the following script:

    下一个变更集仅包含一个编辑。 使用以下脚本重命名了Balances表中先前创建的BalanceType列:

    
    EXEC sp_rename 'dbo.Balances.BalanceType', 'BType', 'COLUMN'
  • The last change we committed is deleting the Sales.CreditCard table:

    我们提交的最后一个更改是删除Sales.CreditCard表:

    
    DROP TABLE Sales.ShoppingCartItem;
  • 修订记录 (Revision history)

    In order to review the entire history of committed changes, start the TortoiseHg Workbench application. It can be started from the right click menu inside the folder initialized as a local Mercurial repository (in this case the MercLocal folder):

    为了查看已提交更改的整个历史记录,请启动TortoiseHg Workbench应用程序。 可以从初始化为本地Mercurial存储库(在此情况下为MercLocal文件夹)的文件夹内的右键单击菜单中启动:

    Double-click the appropriate repository (in this case MercLocal) in the repository tree panel to the left, and the complete history of committed changes will load on the right panel:

    在左侧的存储库树面板中双击适当的存储库(在本例中为MercLocal ),然后将在右侧面板上加载已提交更改的完整历史记录:

    As shown in the above image, the history view presents the task workflow introduced in the article. The first commit (at the bottom of the list) shows initial commit of all database objects, followed by commits where the rest of changes are committed.

    如上图所示,历史视图显示了本文介绍的任务工作流程。 第一个提交(在列表的底部)显示所有数据库对象的初始提交,然后显示提交其余更改的提交。

    Each commit in the list contains the revision ID (the Rev column), branch where it is committed (currently all changes are committed to default branch), description – which is actually the commit message, the author of the commit (all commits are performed by the same user – ApexSQL Test). The Age column stores the time that passed after the commit is performed. The Changes column at the end, shows the exact number of changes included in the specific changeset, along with the appropriate colors that represents the actions performed against committed files:

    列表中的每个提交都包含修订ID(“ 修订”列),提交的分支(当前所有更改都提交给默认分支),描述(实际上是提交消息),提交的作者(执行所有提交)由同一用户-ApexSQL测试)。 “ 年龄”列存储执行提交后经过的时间。 最后的“ 更改”列显示特定更改集中包含的确切更改数量,以及代表针对已提交文件执行的操作的适当颜色:

    For instance, 131 highlighted in green for the first commit (Rev 0) indicates that 131 new objects are committed to the repository. The third changeset (Rev 2) that has 1 highlighted in green and 2 highlighted in orange indicates that one new file (object) is added, and two existing objects were updated/edited. The most recent commit shown on top of the list (Rev 4) where 1 is highlighted in orange indicates that one object is deleted from the repository which corresponds to deleting the ShoppingCartItem table in the last commit.

    例如,在第一次提交( Rev 0 )中以绿色突出显示的131表示有131个新对象已提交到存储库。 第三个变更集( Rev 2 )的绿色突出显示为1,橙色突出显示为2,表示已添加一个新文件(对象),并且已更新/编辑了两个现有对象。 列表( 修订版4 )顶部显示的最新提交(其中1以橙色突出显示)表示已从存储库中删除了一个对象,这与删除最后一个提交中的ShoppingCartItem表相对应。

    单个对象的修订历史 (Revision history for the single object)

    To review the history of the specific object only, navigate to the object in the local folder which is initialized as a Mercurial repository (in this case this is the MercLocal folder) and right click the specific object that you want to compare across revisions (in this case, we’ll review the revision history for the dbo.Balances table), and select the Revision History option:

    要仅查看特定对象的历史记录,请导航到本地文件夹中的对象,该文件夹已初始化为Mercurial存储库(在本例中为MercLocal文件夹),然后右键单击要在各个修订版本之间进行比较的特定对象(在在这种情况下,我们将查看dbo.Balances表的修订历史记录 ,然后选择“ 修订历史记录”选项:

    This initiates the Log file viewer form, that shows the list of changesets which contain the selected file. For the highlighted revision (in this case Rev 1) the version of an object committed in that revision will be shown in the section below:

    这将启动“ 日志文件查看器”表单,该表单显示包含所选文件的变更集的列表。 对于突出显示的修订版(在本例中为Rev 1),该版本中提交的对象的版本将在以下部分中显示:

    Selecting the next revision (Rev 2) from the list, shows that a new column (BalanceType) is added, which is indicated with the green highlighted line (line 18):

    从列表中选择下一个修订版(Rev 2),将显示添加了新列( BalanceType ),并以绿色突出显示的行(第18行)表示:

    Selecting the last revision (Rev 3) where the BalanceType column is renamed to BType will be highlighted in different color (line 18 where the actual change is shown will be highlighted in purple):

    选择将BalanceType列重命名为BType的最后一个修订版( Rev 3 )将以不同的颜色突出显示(显示实际更改的第18行将以紫色突出显示):

    比较两个修订版 (Compare between two revisions)

    To compare between two revisions, select the first one from the commit history, press and hold the CTRL key, select the second revision, and right click any of them. From the right click menu, select the Visual Diff option. In this case, we’ll compare Rev 3 with Rev 1:

    要在两个修订版本之间进行比较,请从提交历史记录中选择第一个修订版本,按住CTRL键,选择第二个修订版本,然后右键单击任何一个。 从右键单击菜单中,选择“ Visual Diff”选项。 在这种情况下,我们将比较Rev 3Rev 1

    This initiates a new form that lists all the differences between selected revisions. In order to show differences for the specific object, double-click that object from the list. We’ll do that for the dbo.Balances table:

    这将启动一个新表格,其中列出了所选修订之间的所有差异。 为了显示特定对象的差异,请从列表中双击该对象。 我们将对dbo.Balances表执行此操作

    比较各个版本中特定对象的版本 (Compare between versions of the specific object across revisions)

    The above described comparison between revisions gives a list of all objects that are compared, so the user can select which one to inspect in details, as we did for the dbo.Balances table. In case we need to inspect differences for the specific object across revision history, there is no need to compare all objects from one changeset with all objects from another changeset. To narrow down the comparison to a single object, select it from the list of objects in any changeset, and from the right click menu select the Compare File Revisions option. We’ll perform that against the dbo.Balances table from the Rev 2 revision:

    修订之间的上述比较给出了所有比较对象的列表,因此用户可以选择要详细检查的对象,就像我们对dbo.Balances表所做的那样 。 如果我们需要检查整个修订历史中特定对象的差异,则无需将一个变更集的所有对象与另一变更集的所有对象进行比较。 要将比较范围缩小到单个对象,请从任何变更集中的对象列表中选择它,然后从右键单击菜单中选择“ 比较文件修订”选项。 我们将针对Rev 2修订版中的dbo.Balances表执行该操作:

    This initiates the Log file viewer form for the selected object. Both sides, left and right, shows the same list of revisions related to specific object (in this case the Balances table). To compare between revisions, simply select one on the left side, and another one on the right (we’ll compare the version of the balances table from Rev 1 with the version from Rev 3):

    这将启动所选对象的日志文件查看器表单。 左右两侧都显示与特定对象相关的相同修订版本列表(在本例中为“ 余额”表)。 要在修订版本之间进行比较,只需在左侧选择一个,在右侧选择另一个(我们将比较Rev 1中的余额表版本和Rev 3中的版本):

    The above image shows that the BType we have introduced in Rev3 didn’t exist in Rev 1 when the Balances table was committed initially.

    上图显示的是BTYPE我们Rev3型已经介绍,当余额表最初承诺没有在版本1存在。

    恢复为特定的修订版 (Revert to the specific revision)

    In case the entire revision needs to be reverted, right click on it from the revision history and select the Revert All Files option:

    如果需要还原整个修订,请在修订历史中右键单击它,然后选择“ 还原所有文件”选项:

    Reverting to Rev 1 discards all changes committed after the Rev 1. This means that BalancesList stored procedure will be deleted, as well as BType column that was committed in the later revision. Checking the Balances table in the local repository gives the following result:

    恢复到修订版1会丢弃在修订版1之后提交的所有更改。 这意味着将删除BalancesList存储过程以及在更高版本中提交的BType列。 检查本地存储库中的余额表将得到以下结果:

    This confirms that the BalanceType column introduced in the next revision, and renamed to BType later, does not exist.

    这确认了在下一个修订版中引入并在以后重命名为BTypeBalanceType列不存在。

    从修订历史记录中获取对象的特定版本 (Get specific version of an object from the revision history)

    In case only specific object(s) need to be reverted, instead of the entire revision, navigate to the specific revision, select one (or multiple files using the CTRL key), and from the right click menu select the Revert to Revision option:

    如果只需要还原特定对象而不是整个修订版本,请导航至该特定修订版本,选择一个(或使用CTRL键的多个文件),然后从右键单击菜单中选择“ 还原为修订版本”选项:

    The above image represents reverting the version of the Balances table from Rev 2, without reverting other changes from the same revision. Selecting the Revert to Revision option from the right click menu gives a confirmation dialog, where optionally all object from the selected revision can be reverted (by checking the Revert all files to this revision option). In order to demonstrate reverting of a single object, this option will be unchecked:

    上面的图像表示从修订版2还原余额表的版本,而未还原同一修订版的其他更改。 从右键单击菜单中选择“ 还原到修订版本”选项,将显示一个确认对话框,在该对话框中,可以选择还原来自选定修订版本的所有对象(通过选中“将所有文件还原到此修订版本”选项)。 为了演示单个对象的还原,将不选中此选项:

    After clicking the OK button, to confirm reverting just the Balances table, let’s inspect the local repository.

    单击“ 确定”按钮后,要确认仅还原“ 余额”表,让我们检查本地存储库。

    The Balances table is shown as changed, and reviewing the actual script shows that BType column committed in Rev 4 is reverted back to BalanceType committed in Rev 2:

    余额表显示为已更改,并且查看实际脚本后发现, 修订版4中提交的BType列已还原为修订版2中提交的BalanceType

    Also, BalancesList stored procedure still exists in the local repository since we have reverted the Balances table only.

    另外,由于我们仅还原了Balances表,因此BalancesList存储过程仍存在于本地存储库中。

    Using this approach, any revision can be reverted, which will actually revert all files from the revision, or selecting specific object(s) from the revision can be reverted without affecting the rest of changes from the revision.

    使用此方法,可以还原任何修订,这实际上将还原该修订中的所有文件,或者可以还原从该修订中选择特定的对象,而不影响该修订的其余更改。

    To see the full version history of a SQL Server database object under source control, you can try ApexSQL Source Control, an SSMS add-in that allows you to put a database under version control, commit all changes to the repository and easily revert any committed change from the history.

    要查看在源代码管理下SQL Server数据库对象的完整版本历史记录 ,可以尝试ApexSQL Source Control,它是一种SSMS加载项,可让您将数据库置于版本控制下 ,将所有更改提交到存储库并轻松还原任何已提交改变历史。

翻译自: https://www.sqlshack.com/revision-history-object-change-sql-database-using-mercurial/

mercurial使用

mercurial使用_使用Mercurial在SQL数据库中对象更改的修订历史记录相关推荐

  1. subversion使用_使用Subversion在SQL数据库中对象更改的修订历史记录

    subversion使用 In previous articles, I have already covered the revision history for Git and Team Foun ...

  2. azure云数据库_在Azure SQL数据库中保护数据的五种方法

    azure云数据库 When storing data in the cloud the main concern companies generally have is whether or not ...

  3. azure云数据库_在Azure SQL数据库中配置电子邮件通知

    azure云数据库 In this article, we will review how to configure email notifications in the Azure SQL sing ...

  4. azure云数据库_在Azure SQL数据库中实现动态数据屏蔽

    azure云数据库 In this article, we will review Dynamic Data Masking in the Azure SQL database. Dynamic Da ...

  5. azure备份存储层分类_如何配置Azure SQL数据库长期保留(LTR)备份

    azure备份存储层分类 In this article, we will review default backup settings, long-term retention (LTR) back ...

  6. ssis导出数据性能_如何使用SSIS将数据从Excel导出到Azure SQL数据库中的多个表

    ssis导出数据性能 In this article, I am going to explain how we can split the data within the excel file an ...

  7. SQL数据库中临时表、临时变量和WITH AS关键词创建“临时表”的区别

    原文链接:https://www.cnblogs.com/zhaowei303/articles/4204805.html SQL数据库中数据处理时,有时候需要建立临时表,将查询后的结果集放到临时表中 ...

  8. Android学习笔记——保存数据到SQL数据库中(Saving Data in SQL Databases)

    知识点: 1.使用SQL Helper创建数据库 2.数据的增删查改(PRDU:Put.Read.Delete.Update) 背景知识: 上篇文章学习了保存文件,今天学习的是保存数据到SQL数据库中 ...

  9. 在SQL数据库中搜索对象的不同方法

    This article explores various ways to search for database objects in SQL database such as tables, st ...

最新文章

  1. 2021-2027年中国玩具行业市场研究及前瞻分析报告
  2. Object not found! The requested URL was not found on this server.... 报错解决方案
  3. 数据仓库中的维度表和事实表概述
  4. BZOJ 2456 : mode
  5. Xcode编译Undefined symbols for architecture xxx 错误总结
  6. 开发函数计算的正确姿势———为 PHP 运行时添加自定义扩展
  7. JZOJ 5439. 【NOIP2017提高A组集训10.31】Calculate
  8. leetcode 455. 分发饼干 思考分析
  9. centos怎么查看用户和用户组
  10. idea—开启Run DashBoard
  11. 数据结构与算法之-----图(基本概念)
  12. 40. Combination Sum II
  13. 林德物料搬运公司成功案例:基于功能需求开发的软件模型质量保障
  14. 写给电脑小白的电脑科普
  15. 全局唯一序列号生成器-支持分布式
  16. Python下的中文分词实现
  17. PDF转Word软件
  18. Spring Boot 应用在 kubernetes 的 sidecar 设计与实战
  19. Mesh网络,让世界“雾”起来 | INE创始人熊羽睿演讲实录
  20. git push报错 protocol error: bad line length character: Acti

热门文章

  1. js中的关键子in的使用方法
  2. 【C#】使用DWM实现无边框窗体阴影或全透窗体
  3. Windows操作系统远程Linux服务器传输文件方法(以EasyDSS云平台、EasyNVR上传部署为例)...
  4. 2018中国域名大会-强调服务与网络信息安全
  5. centos7安装telnet服务
  6. [原创]java WEB学习笔记18:java EE 中的MVC 设计模式(理论)
  7. MVC控制器执行重定向
  8. android 布局中的单位及分辨率自解
  9. (原创)如何进行有符号小数乘法运算?(Verilog)
  10. serve : 无法加载文件 C:\Users\wb\AppData\Roaming\npm\serve.ps1